Skip to content

Wake a pending shutdown when in-flight data is acknowledged - #101

Closed
FrenchToblerone54 wants to merge 1 commit into
narrowlink:mainfrom
FrenchToblerone54:fix-shutdown-wake
Closed

FrenchToblerone54 wants to merge 1 commit into
narrowlink:mainfrom
FrenchToblerone54:fix-shutdown-wake

Conversation

@FrenchToblerone54

Copy link
Copy Markdown

Problem

poll_shutdown sends the FIN only when no data is in flight. If there is some, it returns Pending, but the only waker it registers is the one woken when the session is fully shut down. The ACKs that settle the in-flight data wake write_notify, and nothing is registered there once the caller is shutting down instead of writing. The FIN is therefore never sent unless something else happens to poll the stream again, and the shutdown hangs.

Reproduce

Write a few bytes, call poll_shutdown (it returns Pending), then deliver the peer's ACK for those bytes. The shutdown task is not woken. The new test does this.

Fix

In poll_shutdown, when data is still in flight, register the task's waker on write_notify, which the ACK path already wakes. The next poll then sends the FIN.

Test

shutdown_is_woken_when_in_flight_data_is_acknowledged in src/stream/tcp.rs. It fails without the change ("the ACK did not wake the pending shutdown") and passes with it, and it checks that the FIN goes out on the following poll. cargo test and cargo clippy --all-targets are clean.

poll_shutdown returns Pending while data is in flight, but registered no waker
for the ACKs that settle it, so the FIN was never sent unless something else
polled the stream again. Register the waker on write_notify, which the ACK
path already wakes.
@FrenchToblerone54

FrenchToblerone54 commented Oct 17, 2026 •

Copy link
Copy Markdown
Author

Reopened as #105 with a cleaned-up commit.

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.

1 participant