From dff54ef10a826753d82e51c1724872a04e231a09 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 18 Dec 2023 17:53:52 +0100 Subject: [PATCH] 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. (cherry picked from commit 5b78cbae770e9debab186c4bbf2b708eb4561007) Signed-off-by: Willy Tarreau --- src/mux_h2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 0db90a0..9432e4e 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -4038,7 +4038,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; @@ -4136,7 +4136,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)); } -- 1.7.10.4