From: Willy Tarreau Date: Thu, 31 Mar 2022 14:47:46 +0000 (+0200) Subject: BUG/MAJOR: mux_pt: always report the connection error to the conn_stream X-Git-Tag: v2.6-dev5~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=413713f02a73970122fd41c668b655daa38a98ae;p=thirdparty%2Fhaproxy.git BUG/MAJOR: mux_pt: always report the connection error to the conn_stream Over time we've tried hard to abstract connection errors from the upper layers so that they're reported per stream and not per connection. As early as 1.8-rc1, commit 4ff3b8964 ("MINOR: connection: make conn_stream users also check for per-stream error flag") did precisely this, but strangely only for rx, not for tx (probably that by then send errors were not imagined to be reported that way). And this lack of Tx error check was just revealed in 2.6 by recent commit d1480cc8a ("BUG/MEDIUM: stream-int: do not rely on the connection error once established") that causes wakeup loops between si_cs_send() failing to send via mux_pt_snd_buf() and subscribing against si_cs_io_cb() in loops because the function now rightfully only checks for CS_FL_ERROR and not CO_FL_ERROR. As found by Amaury, this causes aborted "show events -w" to cause haproxy to loop at 100% CPU. This fix theoretically needs to be backported to all versions, though it will be necessary and sufficient to backport it wherever 4ff3b8964 gets backported. --- diff --git a/src/mux_pt.c b/src/mux_pt.c index c5eb8c60b7..2fcd139fad 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -535,6 +535,11 @@ static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t if (ret > 0) b_del(buf, ret); + if (conn->flags & CO_FL_ERROR) { + cs->flags |= CS_FL_ERROR; + TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs); + } + TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){ret}); return ret; } @@ -596,6 +601,11 @@ static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe) ret = conn->xprt->snd_pipe(conn, conn->xprt_ctx, pipe); + if (conn->flags & CO_FL_ERROR) { + cs->flags |= CS_FL_ERROR; + TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs); + } + TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){ret}); return ret; }