]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: Add connection error handling when reading/sending on a pipe
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Oct 2022 10:04:56 +0000 (12:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Oct 2022 15:10:44 +0000 (17:10 +0200)
There is no error handling when we read or write on a pipe. There error is
caught later, in the mux I/O handler. But there is no reason to not do so
here.

There is no reason to backport it because no issue was reported for now
because of this "bug". In all cases, it must be evaluated first.

src/mux_h1.c

index 5739d91d918fd8af2806593a14712a501176ed4a..45173b7dfdd887a30188ae7a55697933e194e01a 100644 (file)
@@ -3760,6 +3760,11 @@ static int h1_rcv_pipe(struct stconn *sc, struct pipe *pipe, unsigned int count)
                h1c->flags &= ~H1C_F_WANT_SPLICE;
                TRACE_STATE("Allow xprt rcv_buf on read0", H1_EV_STRM_RECV, h1c->conn, h1s);
        }
+       if (h1c->conn->flags & CO_FL_ERROR) {
+               se_fl_set(h1s->sd, SE_FL_ERROR);
+               h1c->flags = (h1c->flags & ~H1C_F_WANT_SPLICE) | H1C_F_ST_ERROR;
+               TRACE_DEVEL("connection error", H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
+       }
 
        if (!(h1c->flags & H1C_F_WANT_SPLICE)) {
                TRACE_STATE("notify the mux can't use splicing anymore", H1_EV_STRM_RECV, h1c->conn, h1s);
@@ -3811,6 +3816,12 @@ static int h1_snd_pipe(struct stconn *sc, struct pipe *pipe)
        HA_ATOMIC_ADD(&h1c->px_counters->spliced_bytes_out, ret);
 
   end:
+       if (h1c->conn->flags & CO_FL_ERROR) {
+               se_fl_set(h1s->sd, SE_FL_ERROR);
+               h1c->flags = (h1c->flags & ~H1C_F_WANT_SPLICE) | H1C_F_ST_ERROR;
+               TRACE_DEVEL("connection error", H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
+       }
+
        TRACE_LEAVE(H1_EV_STRM_SEND, h1c->conn, h1s, 0, (size_t[]){ret});
        return ret;
 }