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

wasmtime-wasi: Fix spurious wake-ups in blocking_ of InputStream and OutputStream #10113

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions crates/wasi-io/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ pub trait InputStream: Pollable {
/// Similar to `read`, except that it blocks until at least one byte can be
/// read.
async fn blocking_read(&mut self, size: usize) -> StreamResult<Bytes> {
self.ready().await;
self.read(size)
loop {
// This `ready` call may return early due to `io::ErrorKind::WouldBlock`.
self.ready().await;
let data = self.read(size)?;
if data.is_empty() {
continue;
}
return Ok(data);
}
}

/// Same as the `read` method except that bytes are skipped.
Expand Down
Loading