From: Christopher Faulet Date: Thu, 3 Dec 2026 09:58:06 +0000 (+0100) Subject: BUG/MINOR: mux-h2: emit the end of stream in h2_done_ff() on EOI without data X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=de6e29fd1e20cb0dc4845ad568285973a36d1e20;p=haproxy.git BUG/MINOR: mux-h2: emit the end of stream in h2_done_ff() on EOI without data When the producer reports the end of input during a fast-forward without any data, h2_done_ff() left without emitting anything. It happens for instance when a close-delimited H1 message is fast-forwarded and the read0 is detected while no data were received. The end of the stream was then only reported by h2_do_shutw(), on shutdown, delaying it for no reason. Now, in that case, an empty DATA frame with the ES flag is emitted. If it cannot be emitted, it is still left to h2_do_shutw(). This patch could be backported to all stable versions supporting the zero-copy forwarding (3.0 and above). --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 7d44f107b..e91fe679c 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -8823,19 +8823,27 @@ static size_t h2_done_ff(struct stconn *sc) h2s->flags &= ~H2_SF_MORE_HTX_DATA; } - if (!sd->iobuf.data) + if (sd->iobuf.data) { + total = sd->iobuf.data; + h2_set_frame_size(head, total); + if (es_now) + head[4] |= H2_F_DATA_END_STREAM; + b_add(mbuf, 9); + h2s->sws -= total; + h2c->mws -= total; + } + else if (!es_now || h2_send_empty_data_es(h2s) <= 0) { + /* Nothing was forwarded. On EOI, the end of the stream is + * reported using an empty DATA frame. The room reserved for + * the frame header by h2_nego_ff() is still there, so it + * should not fail. Otherwise, it will be emitted on shutdown. + */ goto end; + } /* Perform a synchronous send but in all cases, consider * everything was already sent from the SC point of view. */ - total = sd->iobuf.data; - h2_set_frame_size(head, total); - if (es_now) - head[4] |= H2_F_DATA_END_STREAM; - b_add(mbuf, 9); - h2s->sws -= total; - h2c->mws -= total; if (h2_send(h2s->h2c)) tasklet_wakeup(h2s->h2c->wait_event.tasklet);