Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix write to flush buffer; fix warnings #368

Merged
merged 2 commits into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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