]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Subscribe for sends if output buffer is not empty in h1_snd_pipe
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Apr 2021 15:27:32 +0000 (17:27 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 May 2021 07:21:00 +0000 (09:21 +0200)
In h1_snd_pipe(), before sending spliced data, we take care to flush the
output buffer by subscribing for sends. However, the condition to do so is
not accurate. We test data remaining in the pipe. It works but it also
unnecessarily subscribes H1C for sends when the output buffer is empty if we
are unable to send all spliced data in one time. Instead, H1C is now
subscribed for sends if output buffer is not empty.

src/mux_h1.c

index 9e4088780db0a09d95123339f8e25786eca67b4f..a1cf3f9d41bc3d7b2305b415cf076fdd16b99624 100644 (file)
@@ -3485,18 +3485,17 @@ static int h1_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
 
        TRACE_ENTER(H1_EV_STRM_SEND, cs->conn, h1s, 0, (size_t[]){pipe->data});
 
-       if (b_data(&h1s->h1c->obuf))
-               goto end;
-
-       ret = cs->conn->xprt->snd_pipe(cs->conn, cs->conn->xprt_ctx, pipe);
-  end:
-       if (pipe->data) {
+       if (b_data(&h1s->h1c->obuf)) {
                if (!(h1s->h1c->wait_event.events & SUB_RETRY_SEND)) {
                        TRACE_STATE("more data to send, subscribing", H1_EV_STRM_SEND, cs->conn, h1s);
                        cs->conn->xprt->subscribe(cs->conn, cs->conn->xprt_ctx, SUB_RETRY_SEND, &h1s->h1c->wait_event);
                }
+               goto end;
        }
 
+       ret = cs->conn->xprt->snd_pipe(cs->conn, cs->conn->xprt_ctx, pipe);
+
+  end:
        TRACE_LEAVE(H1_EV_STRM_SEND, cs->conn, h1s, 0, (size_t[]){ret});
        return ret;
 }