From: Christopher Faulet Date: Thu, 3 Dec 2026 08:27:04 +0000 (+0100) Subject: BUG/MEDIUM: mux-h2: don't lose EOM when the output buffer is full X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=671c393f54ae35be0ae58ed708376c79a73bb156;p=haproxy.git BUG/MEDIUM: mux-h2: don't lose EOM when the output buffer is full When a NOOP block carrying the EOM flag was processed by h2_snd_buf(), an empty DATA frame with the ES flag was emitted to report the end of the message. But if this frame could not be emitted, because the output buffer was full or could not be allocated, the NOOP block was removed anyway and counted as sent. So the end of the message was lost and the END_STREAM was never sent. This could happen when the END_STREAM was received in a separate empty DATA frame (or a standalone FIN for H3) while the H2 connection was congested. A server waiting for the end of the request could then wait until a timeout. On the client side, the END_STREAM was only sent on the stream shutdown. Now, the NOOP block is kept when the empty DATA frame cannot be emitted. The stream is blocked, like for other blocks, and it will be retried when some room is made in the output buffer. This patch must be backported to 3.5. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 7337a57a4..7d44f107b 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -8564,12 +8564,17 @@ static size_t h2_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in if (blk->flags & HTX_BLK_FL_EOM) { h2s->flags &= ~H2_SF_MORE_HTX_DATA; if (!(h2s->flags & H2_SF_BODY_TUNNEL)) { - if (h2_send_empty_data_es(h2s) > 0) { - if (h2s->st == H2_SS_OPEN) - h2s->st = H2_SS_HLOC; - else - h2s_close(h2s); - } + /* If the empty DATA frame cannot be + * emitted (no room or error), the + * NOOP block must be kept to not + * lose the end of the message. + */ + if (h2_send_empty_data_es(h2s) <= 0) + goto done; + if (h2s->st == H2_SS_OPEN) + h2s->st = H2_SS_HLOC; + else + h2s_close(h2s); } } htx_remove_blk(htx, blk);