-
Notifications
You must be signed in to change notification settings - Fork 804
fix: improve state transitions of Windows named pipes #1903
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
Merged
Thomasdezeeuw
merged 7 commits into
tokio-rs:master
from
thomaseizinger:fix/panic-invalid-state
Oct 16, 2025
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
140ccc3
fix: handle `State::Error` in `read_done`
thomaseizinger 5da2221
fix: handle `State::Err` in `write_done`
thomaseizinger 0a1e9cb
refactor: match on all variants of `State`
thomaseizinger c7e131e
docs: explain why we leave the state in `None`
thomaseizinger 149f8f0
fix: handle `State::Ok` in `read_done`
thomaseizinger 5c2bdd7
refactor: explicitly match all variants of `State`
thomaseizinger 64fc40e
chore: remove outdated comment
thomaseizinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -875,6 +875,13 @@ fn read_done(status: &OVERLAPPED_ENTRY, events: Option<&mut Vec<Event>>) { | |
| // Move from the `Pending` to `Ok` state. | ||
| let mut io = me.io.lock().unwrap(); | ||
| let mut buf = match mem::replace(&mut io.read, State::None) { | ||
| State::Ok(buf, pos) => { | ||
| io.read = State::Ok(buf, pos); | ||
|
|
||
| // Flag readiness that we have undelivered data to be read. | ||
| io.notify_readable(&me, events); | ||
| return; | ||
| } | ||
| State::Pending(buf, _) => buf, | ||
| State::Err(e) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifically, I think this can be triggered here: https://github.com/thomaseizinger/mio/blob/64fc40ef248af392e1b01b0d4749506927cbc4cd/src/sys/windows/named_pipe.rs#L742 |
||
| io.read = State::Err(e); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am not sure this can happen but it seems safe to just handle it. If
read_doneis called twice in a row, this could possibly trigger but I don't know enough about the internals here and how Windows handles this to say for sure.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.
All we do further down is notify that the buffer needs to be consumed. If we are still in
Ok, I am guessing this means it hasn't been consumed yet.