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 Feb 14, 2024
1 parent 57fa569 commit 302a0ed
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/src/sync/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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/src/tokio/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 302a0ed

Please sign in to comment.