]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Always subscribe for reads when splicing is disabled
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 9 Apr 2021 09:58:49 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 May 2021 07:21:00 +0000 (09:21 +0200)
In h1_rcv_pipe(), when the splicing is not possible or disabled at the end
of the fnuction, we make sure to subscribe for reads. It is not a bug but it
avoid an extra call to h1_rcv_pipe() to handle the subscription in some
cases (end of message, end of chunk or read0).

In addition, the condition to detect end of splicing has been simplified. We
now only rely on H1C_F_WANT_SPLICE flags.

src/mux_h1.c

index a1cf3f9d41bc3d7b2305b415cf076fdd16b99624..04a90e8c89822a221b25488d02dc53d2ed525bae 100644 (file)
@@ -3432,10 +3432,6 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c
        if ((h1m->flags & H1_MF_CHNK) || (h1m->state != H1_MSG_DATA && h1m->state != H1_MSG_TUNNEL)) {
                h1c->flags &= ~H1C_F_WANT_SPLICE;
                TRACE_STATE("Allow xprt rcv_buf on !(msg_data|msg_tunnel)", H1_EV_STRM_RECV, cs->conn, h1s);
-               if (!(h1c->wait_event.events & SUB_RETRY_RECV)) {
-                       TRACE_STATE("restart receiving data, subscribing", H1_EV_STRM_RECV, cs->conn, h1s);
-                       cs->conn->xprt->subscribe(cs->conn, cs->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
-               }
                goto end;
        }
 
@@ -3467,11 +3463,13 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c
                TRACE_STATE("Allow xprt rcv_buf on read0", H1_EV_STRM_RECV, cs->conn, h1s);
        }
 
-       if ((h1s->flags & H1S_F_REOS) ||
-           (h1m->state != H1_MSG_TUNNEL && h1m->state != H1_MSG_DATA) ||
-           (h1m->state == H1_MSG_DATA && !h1m->curr_len)) {
+       if (!(h1c->flags & H1C_F_WANT_SPLICE)) {
                TRACE_STATE("notify the mux can't use splicing anymore", H1_EV_STRM_RECV, h1c->conn, h1s);
                cs->flags &= ~CS_FL_MAY_SPLICE;
+               if (!(h1c->wait_event.events & SUB_RETRY_RECV)) {
+                       TRACE_STATE("restart receiving data, subscribing", H1_EV_STRM_RECV, cs->conn, h1s);
+                       cs->conn->xprt->subscribe(cs->conn, cs->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
+               }
        }
 
        TRACE_LEAVE(H1_EV_STRM_RECV, cs->conn, h1s, 0, (size_t[]){ret});