From: Christopher Faulet Date: Mon, 18 Dec 2023 16:53:52 +0000 (+0100) Subject: BUG/MEDIUM: mux-h2: Switch pending error to error if demux buffer is empty X-Git-Tag: v3.0-dev1~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b78cbae770e9debab186c4bbf2b708eb4561007;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mux-h2: Switch pending error to error if demux buffer is empty When an error on the H2 connection is detected when sending data, only a pending error is reported, waiting for an error or a shutdown on the read side. However if a shutdown was already received, the pending error is switched to a definitive error. At this stage, we must also wait to have flushed the demux buffer. Otherwise, if some data must still be demux, messages for one or more streams may be truncated. There is already the flag H2_CF_END_REACHED to know a shutdown was received and we no longer progress on demux side (buffer empty or data truncated). On sending side, we should use this flag instead to report a definitive error. This patch is part of a series that should fix a bug reported in issue #2388 (#2388#issuecomment-1855735144). Backport instructions will be shipped in the last commit of the series. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index ff2d115f73..cdd1e3eaeb 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3992,7 +3992,7 @@ static int h2_send(struct h2c *h2c) if (h2c->flags & (H2_CF_ERROR|H2_CF_ERR_PENDING)) { TRACE_DEVEL("leaving on error", H2_EV_H2C_SEND, h2c->conn); - if (h2c->flags & H2_CF_RCVD_SHUT) + if (h2c->flags & H2_CF_END_REACHED) h2c->flags |= H2_CF_ERROR; b_reset(br_tail(h2c->mbuf)); h2c->idle_start = now_ms; @@ -4090,7 +4090,7 @@ static int h2_send(struct h2c *h2c) if (conn->flags & CO_FL_ERROR) { h2c->flags |= H2_CF_ERR_PENDING; - if (h2c->flags & H2_CF_RCVD_SHUT) + if (h2c->flags & H2_CF_END_REACHED) h2c->flags |= H2_CF_ERROR; b_reset(br_tail(h2c->mbuf)); }