fix(http1): synchronize dispatch shutdown with sends - #4150
Open
fzlzjerry wants to merge 1 commit into
Open
Conversation
Serialize HTTP/1 envelope publication with receiver shutdown so a send cannot finish after the receiver has drained and dropped the channel. Closes hyperium#4122
fzlzjerry
marked this pull request as ready for review
August 11, 2026 08:57
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.
Fixes #4122.
Summary
Background
Tokio's unbounded channel reserves message capacity before it publishes the
envelope into the channel list. Receiver shutdown could close and drain the
channel during that window. The send would then finish after shutdown, leaving
the request owned by the channel until the remaining
SendRequestwas dropped.The shared lock makes publication and HTTP/1 receiver shutdown linearizable.
The HTTP/2
UnboundedSenderpath remains unchanged.Validation
cargo test --features fullcargo clippy --features full -- -D warningscargo check --no-default-features --features client,http1cargo check --no-default-features --features client,http2cargo check --no-default-features --features client,http1,http2change
giver_queue_throughputbenchmark: master 479.70/486.63 ns per iteration;this change 471.91/470.48 ns per iteration (within benchmark variance)