BUG/MEDIUM: mux-h1: only turn CO_FL_ERROR to CS_FL_ERROR with empty ibuf
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Mar 2022 16:10:36 +0000 (17:10 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 28 Mar 2022 20:39:07 +0000 (22:39 +0200)
A connection-level error must not be turned to a stream-level error if there
are still pending data for that stream, otherwise it can cause the truncation
of the last pending data.

This must be backported to affected releases, at least as far as 2.4,
maybe further.

(cherry picked from commit 99bbdbcc21355c8773474274a319086c0d2999d6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3062447a332684cff7e247e316466729e8d34dbc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a352e82cb8e7fc98b321cc6b6b283a0ae96e100b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/mux_h1.c

index 520c48c..e336165 100644 (file)
@@ -2315,7 +2315,7 @@ static int h1_process(struct h1c * h1c)
        if (!h1s_data_pending(h1s) && h1s && h1s->cs && h1s->cs->data_cb->wake &&
            (h1s->flags & H1S_F_REOS || h1c->flags & H1C_F_CS_ERROR ||
            conn->flags & (CO_FL_ERROR | CO_FL_SOCK_WR_SH))) {
-               if (h1c->flags & H1C_F_CS_ERROR || conn->flags & CO_FL_ERROR)
+               if (h1c->flags & H1C_F_CS_ERROR || ((conn->flags & CO_FL_ERROR) && !b_data(&h1c->ibuf)))
                        h1s->cs->flags |= CS_FL_ERROR;
                TRACE_POINT(H1_EV_STRM_WAKE, h1c->conn, h1s);
                h1s->cs->data_cb->wake(h1s->cs);