Repository navigation
fix(mux): stop spinning the session loop on a frontend hang-up - #1777
Merged
Merged
Conversation
Mux::ready_inner handled a frontend HUP only on entry. When it delayed the close for a pending flush and that flush completed inside the inner loop, the frontend's remaining readiness was HUP alone, which the exit check counted as work although nothing in the loop acts on it: the loop ran to MAX_LOOP_ITERATIONS and counted http.infinite_loop.error before the session closed. The inner loop now closes the session on a frontend HUP once no output is left to flush, except on a lingering frontend, which it leaves to drain the client's last bytes to the EOF as the entry check does. Its exit check counts only frontend READABLE, WRITABLE and ERROR interest, so a flush blocked on the socket yields to the next readiness event instead of spinning. Fixes #1774 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/mux-frontend-hup-loop
branch
from
October 1, 2026 18:04
ee0b33a to
c3a4eb2
Compare
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.
After a client hang-up,
Mux::ready_innercould run its inner loop toMAX_LOOP_ITERATIONS(countinghttp.infinite_loop.error) before closing the session: the frontend HUP was handled only on entry, and once a delayed flush completed inside the loop the remaining HUP was counted as work although nothing in the loop acts on it.Fix: the inner loop closes the session on a frontend HUP once no output is left to flush, except on a lingering frontend (RFC 9112 §9.6), which it leaves to drain the client's last bytes to the EOF, as the entry check does. Its exit check counts only frontend READABLE, WRITABLE and ERROR interest, so a flush blocked on the socket yields to the next readiness event instead of spinning.
Tests:
test_h2_frontend_hangup_does_not_spin:http.infinite_loop.errorstays at 0 after an H2 client hangs up following a complete exchange.a_hup_during_the_flush_that_starts_a_linger_drains_before_closing: a TLS-like frontend hangs up while the answer to a partial request is still buffered; the linger started inside the loop drains the rest of the request before the close.Fixes #1774