-
Notifications
You must be signed in to change notification settings - Fork 751
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
peek blocks after read on windows #1755
Comments
Can you reproduce the error with Mio types (not Tokio)? |
If you look at the other issue someone did indeed reproduce it only with mio |
Then why do you include an example using Tokio in an issue for Mio? |
I am sorry this is the first time I try to contribute to the project, the line between the projects were still a bit blurry to me. It was just a simpler example for me to use. I figured I could try to help since the original issue didn't get much traction. |
Since we are not sure who's fault it is, I will close the issue for now. If someone has the same problem feel free to re-open with a proper mio example. |
I left a comment in the Tokio thread, but if there is a problem with Mio then I still like to know, so feel free to reopen when/if it's clear it a problem with Mio. |
I commented back, unsure if I have enough knowledge to create a reproduction. I didn't see any test around peek in mio though, so at the very least adding a test to confirm that mio is working as intended would be good. That would need to check that:
If and only if this is the case for all platform would I consider mio "bug free". I highly suspect that the last check will fail on unix platforms, but maybe not. |
Hi! I wanted to continue the issue of tokio-rs/tokio#3789
I used the following code as reproduction:
So I don't know much about Tokio internals, but I spent the last couple of hours debugging.
I found that the waker for the
Readiness
future used by peek is never called after there was one call to read. Digging deeper theGetQueuedCompletionStatusEx
is blocking when issuing the peek after read.I think this is because Windows doesn't know we are interested by
READABLE
because peek never registers the fact that it has theREADABLE
interest at the OS level. It does register the interest at theScheduledIO
level but we never get there obviously because the thread is parked.When we issue a
read
we use theIoSourceState
whichreregisters
our interests with the IOCP if it would block, but when we peek we directly use the STD IO. See:mio/src/net/tcp/stream.rs
Lines 210 to 212 in 08ee541
I think the fix is to use
IoSourceState::do_io
when we peek, but I must test it.The text was updated successfully, but these errors were encountered: