Skip to content

Fix stale read/write/connect state leaking across named pipe reuse on Windows - #2002

Open
Dantsz wants to merge 17 commits into
tokio-rs:masterfrom
Dantsz:connectdisconnectpipefix
Open

Fix stale read/write/connect state leaking across named pipe reuse on Windows#2002
Dantsz wants to merge 17 commits into
tokio-rs:masterfrom
Dantsz:connectdisconnectpipefix

Conversation

@Dantsz

@Dantsz Dantsz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #1983.

Read and write completions now carry the generation they were issued under (inspired by the Solaris Event Port implementation), so results from an in-flight operation that outlived the connection are discarded instead of leaking to the next client. disconnect bumps that generation and cancels or clears the pending read/write state.

connect tracks its own generation so an aborted ConnectNamedPipe can no longer park a stale error for the next successful connection.

Regression tests added:

  • issue_1983 — two connect/read/disconnect rounds on one instance(from issue)
  • issue_1983_2 — read still pending at disconnect
  • issue_1983_3 — completed but unread data buffered at disconnect
  • issue_1983_4 — write in flight when the client goes away
  • issue_1983_5 — connect aborted by disconnect

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.

Windows named pipe: stale read state leaks across DisconnectNamedPipe/ConnectNamedPipe instance reuse

1 participant