Skip to content

Commit

Permalink
Merge pull request #5321 from wasmerio/fix/flush-before-close
Browse files Browse the repository at this point in the history
Flush before closing files to avoid missed writes
  • Loading branch information
Arshia001 authored Jan 3, 2025
2 parents 88ffb5d + 88cc705 commit 193ea9c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/wasix/src/syscalls/wasi/fd_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ pub fn fd_close(mut ctx: FunctionEnvMut<'_, WasiEnv>, fd: WasiFd) -> Result<Errn
return Ok(Errno::Success);
}
}

// HACK: we use tokio files to back WASI file handles. Since tokio
// does writes in the background, it may miss writes if the file is
// closed without flushing first. Hence, we flush once here.
wasi_try_ok!(__asyncify_light(env, None, state.fs.flush(fd))?);
wasi_try_ok!(state.fs.close_fd(fd));

#[cfg(feature = "journal")]
Expand Down

0 comments on commit 193ea9c

Please sign in to comment.