]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Properly report EOI/ERROR on read0 in h1_rcv_pipe()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Mar 2023 16:29:47 +0000 (17:29 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:05 +0000 (08:57 +0200)
In h1_rcv_pipe(), only the end of stream was reported when a read0 was
detected. However, it is also important to report the end of input or an
error, depending on the message state. This patch does not fix any real
issue for now, but some others, specific to the 2.8, rely on it.

No backport needed.

src/mux_h1.c

index e277e8f78701590683fd8abc7e460c1726d5c509..f6d385b28235ecb6b314f7f4cee473010cbe9885 100644 (file)
@@ -3849,6 +3849,18 @@ static int h1_rcv_pipe(struct stconn *sc, struct pipe *pipe, unsigned int count)
   end:
        if (conn_xprt_read0_pending(h1c->conn)) {
                se_fl_set(h1s->sd, SE_FL_EOS);
+               TRACE_STATE("report EOS to SE", H1_EV_STRM_RECV, h1c->conn, h1s);
+               if (h1m->state >= H1_MSG_DONE || !(h1m->flags & H1_MF_XFER_LEN)) {
+                       /* DONE or TUNNEL or SHUTR without XFER_LEN, set
+                        * EOI on the stream connector */
+                       se_fl_set(h1s->sd, SE_FL_EOI);
+                       TRACE_STATE("report EOI to SE", H1_EV_STRM_RECV, h1c->conn, h1s);
+               }
+               else {
+                       se_fl_set(h1s->sd, SE_FL_ERROR);
+                       h1c->flags = (h1c->flags & ~H1C_F_WANT_SPLICE) | H1C_F_ERROR;
+                       TRACE_ERROR("message aborted, set error on SC", H1_EV_STRM_RECV|H1_EV_H1S_ERR, h1c->conn, h1s);
+               }
                h1c->flags = (h1c->flags & ~H1C_F_WANT_SPLICE) | H1C_F_EOS;
                TRACE_STATE("Allow xprt rcv_buf on read0", H1_EV_STRM_RECV, h1c->conn, h1s);
        }