]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: mux-h1: Don't shortcut h1_process() while a stream is attached
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Nov 2026 14:44:29 +0000 (15:44 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 24 Nov 2026 14:49:48 +0000 (15:49 +0100)
commit7fb0bb581774d80dee1805209c9767685210a5b8
treeb48ef653205dbd348bc0e7e6781de5b942985810
parent4dc888d04475d825a24344b23c4448f86905f729
BUG/MEDIUM: mux-h1: Don't shortcut h1_process() while a stream is attached

Commit 8fc09da21 ("BUG/MEDIUM: mux-h1: don't drop pending output on a short
content-length") generalized the condition in h1_process() that releases an
H1 connection ASAP from delayed silent shutdowns to any connection in
CLOSING state with an empty output buffer. But it also caught connections
still in CLOSING with an H1 stream attached, which is exactly what
h1_close() leaves behind when the shutdown is performed while the stream is
not detached yet.

On the backend side of a tunnel after a 101 Switching Protocols, this is
fatal: when the stream forwards the client's half-close, h1_close() sets the
h1c to CLOSING but keeps the h1s attached. On the next wakeup, h1_process()
enters the release block, and, because the state is not RUNNING, it calls
h1_close() (a no-op) and jumps to the end, skipping the final
h1_wake_stream_for_recv() call. With H1C_F_WANT_FASTFWD set the mux does not
read the transport itself and never re-subscribes, so the server's data and
FIN are not seen until the shut timeout fires (timeout server). Websocket
sessions half-closed by clients then stall for timeout server and end with
SD--/sD-- instead of ending promptly with ----.

Now, the release block is only entered when no H1 stream is attached, or
when a silent shutdown was requested. This preserves the short
content-length fix (in that case h1s_destroy() has already set h1c->h1s to
NULL when h1_close() leaves the h1c in CLOSING) while restoring the
pre-8fc09da21 behavior for connections with an attached stream.

H1C_F_SILENT_SHUT must remain part of the condition because it is the only
case where an H1C in CLOSING state with an attached stream must still be
released as soon as its output buffer is drained: a silent (dirty) shutdown
means we never send a clean FIN to the peer (conn_sock_shutw() skips
shutdown(SHUT_WR)), so nothing can happen on the connection anymore and the
stream will never have data to fast-forward. It is set on aborted/torn-down
streams and on delayed dirty shutdowns, where the peer will never
acknowledge the close.  Dropping it from the condition would resurrect the
bug fixed by 753083041 ("BUG/MEDIUM: mux-h1: Handle delayed silent shut in
h1_process() to release H1C", issues #1448/#1453): such connections would
linger until the client or server timeout instead of being released once the
last pending bytes are sent.

This patch should fix issues #3579 and #3601. It must be backported wherever
8fc09da21 was backported, so at least as far as 2.8.
src/mux_h1.c