Skip to content

fix(mux): stop spinning the session loop on a frontend hang-up - #1777

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
fix/mux-frontend-hup-loop
Oct 1, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
fix/mux-frontend-hup-loop

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

After a client hang-up, Mux::ready_inner could run its inner loop to MAX_LOOP_ITERATIONS (counting http.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:

  • e2e test_h2_frontend_hangup_does_not_spin: http.infinite_loop.error stays at 0 after an H2 client hangs up following a complete exchange.
  • unit 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

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
FlorentinDUBOIS force-pushed the fix/mux-frontend-hup-loop branch from ee0b33a to c3a4eb2 Compare October 1, 2026 18:04
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 8357a31 into main Oct 1, 2026
22 of 23 checks passed
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.

fix(mux): a frontend hang-up spins the session loop to its iteration budget

1 participant