Skip to content

Commit

Permalink
Merge #368
Browse files Browse the repository at this point in the history
368: fix write to flush buffer; fix warnings r=MarkMcCaskey a=MarkMcCaskey

resolves #363 

Co-authored-by: Mark McCaskey <[email protected]>
  • Loading branch information
bors[bot] and Mark McCaskey committed Apr 20, 2019
2 parents f7e4a09 + 9256f6e commit 363b46e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
5 changes: 3 additions & 2 deletions lib/wasi/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -236,7 +237,7 @@ impl WasiFs {
fn get_inode(&mut self, path: &str) -> Option<Inode> {
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)
Expand Down
6 changes: 5 additions & 1 deletion lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ fn write_bytes<T: Write>(
let bytes = iov_inner.buf.deref(memory, 0, iov_inner.buf_len)?;
write_loc
.write(&bytes.iter().map(|b_cell| b_cell.get()).collect::<Vec<u8>>())
.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)
}

Expand Down

0 comments on commit 363b46e

Please sign in to comment.