-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 lost Waker
instances with async stdio streams
#8782
Fix lost Waker
instances with async stdio streams
#8782
Conversation
This commit fixes a bug in the `Subscribe` trait implementation for `AsyncStd{in,out}Stream` structures in the `wasmtime-wasi` crate. Previously these implementations would create a future for the duration of a single `poll` but then the future was dropped which could lead to lost wakeups as the waker is gone after the future is dropped. The fix was to use a `tokio::sync::Mutex` here instead of a `std::sync::Mutex` and leave some comments about why contention isn't expected. Closes bytecodealliance#8781
}); | ||
|
||
let mut buf = [0; 100]; | ||
let n = read.read(&mut buf).await.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be more comfortable with this test if the amount read was in excess of the buffer sizes in the io::duplex and the AsyncWriteStream. You could just lower those to 32 each.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. Thank you!
Why not just use |
Semantically these are all non-blocking functions, not blocking ones, so blocking on contention isn't appropriate for them. |
This commit fixes a bug in the
Subscribe
trait implementation forAsyncStd{in,out}Stream
structures in thewasmtime-wasi
crate. Previously these implementations would create a future for the duration of a singlepoll
but then the future was dropped which could lead to lost wakeups as the waker is gone after the future is dropped. The fix was to use atokio::sync::Mutex
here instead of astd::sync::Mutex
and leave some comments about why contention isn't expected.Closes #8781