Repository navigation
fix(mux-h1): clear end-of-stream flags on the keep-alive stream reset - #1782
Merged
Merged
Conversation
FlorentinDUBOIS
force-pushed
the
fix/h1-keep-alive-h2-backend-reuse
branch
from
October 1, 2026 21:29
ab3ef0d to
2bfd353
Compare
With an H1 client in front of an H2 backend, ConnectionH1::writable reused the client stream slot for the next request without clearing back_received_end_of_stream, front_received_end_of_stream and the per-direction DATA counters, which Context::create_stream clears for a recycled slot. The stale end-of-stream flag made the H2 backend connection refuse the second response's HEADERS as arriving on a closed stream (RFC 9113 section 5.1) and send GOAWAY(STREAM_CLOSED), so the client got a 502. The keep-alive reset now clears them. Closes #1781 Signed-off-by: Florentin Dubois <[email protected]>
Cover a GET, four 600000-byte POSTs and a GET on one H1 client connection over one H2 backend connection, with the default and a 16384-byte backend initial window: each request must start from the backend's own window, which ConnectionH2::start_stream sizes, and the backend must see one connection. The H2 mock backend counts accepted connections and can advertise a stream window. Assert in ConnectionH2::start_stream that the backend leg of a slot is fresh, and name in LIFECYCLE.md section 3.2 exactly what the keep-alive reset clears and what it leaves to create_stream's other paths. Refs #1781 Signed-off-by: Florentin Dubois <[email protected]>
Without the keep-alive reset of the end-of-stream flag, a debug build panics on the fresh-backend-leg assertion of start_stream before any 502; without the backend-leg window sizing, only the small-window variant fails, at its fourth POST. Refs #1781 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h1-keep-alive-h2-backend-reuse
branch
from
October 2, 2026 01:41
15d4bbc to
eb35f64
Compare
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Brings in #1787 and #1782; the only conflicts were pinned h2.rs line citations in doc/h2_mux_internals.md, repointed. Also fixes the merged reset-stream handling: - An empty DATA frame without END_STREAM on a stream this endpoint reset never reached handle_data_frame, so it skipped the empty-DATA flood counter (CVE-2019-9518) and fit any window allowance for free. The was_reset_locally branch now counts it toward that limit like a live stream does. - The DATA and header-block allowances are held for at most 512 reset streams: a stream refused or reset untracked stays in rst_sent and never enters the ring its allowances are dropped with. - The docs say "the stream's initial receive window", state how empty DATA counts, and note that a backend connection's allowances are bounded by the backend's own concurrency, not the emitted-RST cap. Refs #1783 Signed-off-by: Florentin Dubois <[email protected]>
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.
With an H1 client in front of an H2 backend, the second request on a keep-alive client connection was answered 502.
ConnectionH1::writablereused the client stream slot without clearing the end-of-stream flags and DATA counters thatContext::create_streamclears for a recycled slot. The H2 backend connection then refused the second response's HEADERS as arriving on a closed stream (RFC 9113 §5.1) and sent GOAWAY(STREAM_CLOSED).The keep-alive reset now clears them, and
ConnectionH2::start_streamasserts (debug builds) that the backend leg is fresh. The backend leg's send window is sized from the backend's SETTINGS_INITIAL_WINDOW_SIZE since #1757: without it, a keep-alive request started from what the previous one left of the window, so large request bodies stalled, and a backend advertising less than 65 535 was over-run.Tests,
e2e/src/tests/tests.rs:test_h1_to_h2_keep_alive_requeststest_h1_to_h2_keep_alive_requests_small_backend_windowEach sends a GET, four 600 000-byte POSTs and a GET on one client connection, and asserts one backend connection and six backend requests, with the default and a 16 384-byte backend window. Both fail without #1757:
[true, false, …]with the small window,[true, true, true, false, …]with the default. The H2 mock backend now counts accepted connections and can advertise a stream window. Documented inlib/src/protocol/mux/LIFECYCLE.md§3.2 andCHANGELOG.md.Fixes #1781