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

Add do_io on peek for TcpStream #1756

Closed
wants to merge 1 commit into from
Closed

Conversation

Sytten
Copy link

@Sytten Sytten commented Jan 25, 2024

Fixes #1755
I am not sure of the implications of this change for all platforms, but it fixes the issue on windows. I believe it should be fine on unix too, but more tests are needed.

@Sytten

This comment was marked as off-topic.

Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. Peeking shouldn't reset our readiness internally as more data can be read (when not peeking).

@Thomasdezeeuw
Copy link
Collaborator

FYI its a potential security issue that cirrus ci runs without any approval, probably should restrict that...

We have no secrets, so it's not really.

@Sytten
Copy link
Author

Sytten commented Jan 25, 2024

This is incorrect. Peeking shouldn't reset our readiness internally as more data can be read (when not peeking).

I am not sure I understand what that means. A peek does currently reset internal readiness if it would would block which is fine since we need to wait for more data to come in. A read also reset internal readiness. If you don't reregister the interest with the OS when that happens (which is essentially what do_io does) then I am not sure how we expect this to work at all. I am a bit surprised that Unix currently work, seems more like an accident than planned behaviour to me but I didnt check the code much.

@Thomasdezeeuw
Copy link
Collaborator

If a peek call returns a short read (peek) on Unix it will trigger our internal registering mechanism, but it shouldn't.

@Sytten
Copy link
Author

Sytten commented Jan 25, 2024

Does internal mean the readiness stored in ScheduledIO or the libc/iocp calls?
EDIT: This is not relevant for mio, internal means the registry if I understand correctly

Each read does a reregister if it would block, so I fail to understand why that would be a bad thing for a peek to do it too. But I probably don't understand the implications of reregister, the name suggest it is idempotent.

Now moving forward if this is not the solution what is? Is it to only reregister on windows? Is it to not clear readiness on WouldBlock (that seems wrong)?

@Sytten
Copy link
Author

Sytten commented Jan 25, 2024

PR is incorrect closing

@Sytten Sytten closed this Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

peek blocks after read on windows
2 participants