Repository navigation
Wake a pending shutdown when in-flight data is acknowledged - #101
Closed
FrenchToblerone54 wants to merge 1 commit into
Closed
FrenchToblerone54 wants to merge 1 commit into
FrenchToblerone54 wants to merge 1 commit into
Conversation
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
force-pushed
the
fix-shutdown-wake
branch
from
October 17, 2026 08:54
33cac58 to
a0a2ee0
Compare
Author
|
Reopened as #105 with a cleaned-up commit. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
poll_shutdownsends the FIN only when no data is in flight. If there is some, it returnsPending, 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 wakewrite_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 returnsPending), 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 onwrite_notify, which the ACK path already wakes. The next poll then sends the FIN.Test
shutdown_is_woken_when_in_flight_data_is_acknowledgedinsrc/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 testandcargo clippy --all-targetsare clean.