Skip to content

Commit

Permalink
Discard empty writes in wasi-common as well
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Dec 6, 2023
1 parent 4930670 commit da98aa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/wasi-common/cap-std-sync/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ impl WasiFile for File {
bufs: &[io::IoSlice<'a>],
offset: u64,
) -> Result<u64, Error> {
if bufs.iter().map(|i| i.len()).sum::<usize>() == 0 {
return Ok(0);
}
let n = self.0.write_vectored_at(bufs, offset)?;
Ok(n.try_into()?)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/wasi-common/tokio/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ macro_rules! wasi_file_impl {
bufs: &[io::IoSlice<'a>],
offset: u64,
) -> Result<u64, Error> {
if bufs.iter().map(|i| i.len()).sum::<usize>() == 0 {
return Ok(0);
}
block_on_dummy_executor(move || self.0.write_vectored_at(bufs, offset))
}
async fn seek(&self, pos: std::io::SeekFrom) -> Result<u64, Error> {
Expand Down

0 comments on commit da98aa5

Please sign in to comment.