Skip to content

fix(http1): synchronize dispatch shutdown with sends - #4150

Open
fzlzjerry wants to merge 1 commit into
hyperium:masterfrom
fzlzjerry:fix/h1-dispatch-race
Open

fix(http1): synchronize dispatch shutdown with sends#4150
fzlzjerry wants to merge 1 commit into
hyperium:masterfrom
fzlzjerry:fix/h1-dispatch-race

Conversation

@fzlzjerry

Copy link
Copy Markdown
Contributor

Fixes #4122.

Summary

  • serialize HTTP/1 envelope publication with receiver shutdown
  • close the receiver under the same synchronization boundary before teardown
  • add regression coverage for a concurrent send and connection shutdown

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 SendRequest was dropped.

The shared lock makes publication and HTTP/1 receiver shutdown linearizable.
The HTTP/2 UnboundedSender path remains unchanged.

Validation

  • cargo test --features full
  • cargo clippy --features full -- -D warnings
  • cargo check --no-default-features --features client,http1
  • cargo check --no-default-features --features client,http2
  • cargo check --no-default-features --features client,http1,http2
  • 500,000-iteration issue stress test: 23 missed drops on master, 0 with this
    change
  • giver_queue_throughput benchmark: master 479.70/486.63 ns per iteration;
    this change 471.91/470.48 ns per iteration (within benchmark variance)

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
fzlzjerry marked this pull request as ready for review August 11, 2026 08:57
Copilot AI lite review requested due to automatic review settings August 11, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Body dropped too late when an h1 handshake hits an error

2 participants