diff --git a/CHANGELOG.md b/CHANGELOG.md index 14462c4fc6f..01163915a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All PRs to the Wasmer repository must add to this file. Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#368](https://github.com/wasmerio/wasmer/pull/368) Fix issue with write buffering - [#343](https://github.com/wasmerio/wasmer/pull/343) Implement preopened files for WASI and fix aligment issue when accessing WASI memory - [#367](https://github.com/wasmerio/wasmer/pull/367) Add caching support to the LLVM backend. - [#366](https://github.com/wasmerio/wasmer/pull/366) Remove `UserTrapper` trait to fix [#365](https://github.com/wasmerio/wasmer/issues/365). diff --git a/lib/wasi/src/state.rs b/lib/wasi/src/state.rs index d703e2032d0..65cc3e6a88e 100644 --- a/lib/wasi/src/state.rs +++ b/lib/wasi/src/state.rs @@ -12,12 +12,13 @@ use std::{ time::SystemTime, }; use wasmer_runtime_core::debug; -use zbox::{init_env as zbox_init_env, FileType, OpenOptions, Repo, RepoOpener}; +use zbox::init_env as zbox_init_env; pub const MAX_SYMLINKS: usize = 100; #[derive(Debug)] pub enum WasiFile { + #[allow(dead_code)] ZboxFile(zbox::File), HostFile(fs::File), } @@ -236,7 +237,7 @@ impl WasiFs { fn get_inode(&mut self, path: &str) -> Option { Some(match self.name_map.entry(path.to_string()) { Entry::Occupied(o) => *o.get(), - Entry::Vacant(v) => { + Entry::Vacant(_v) => { return None; // let file = if let Ok(file) = OpenOptions::new() // .read(true) diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 455d210d424..a436444fbd7 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -37,11 +37,15 @@ fn write_bytes( let bytes = iov_inner.buf.deref(memory, 0, iov_inner.buf_len)?; write_loc .write(&bytes.iter().map(|b_cell| b_cell.get()).collect::>()) - .map_err(|_| __WASI_EIO)?; + .map_err(|_| { + write_loc.flush(); + __WASI_EIO + })?; // TODO: handle failure more accurately bytes_written += iov_inner.buf_len; } + write_loc.flush(); Ok(bytes_written) }