From: Christopher Faulet Date: Tue, 6 Apr 2021 15:27:32 +0000 (+0200) Subject: MINOR: mux-h1: Subscribe for sends if output buffer is not empty in h1_snd_pipe X-Git-Tag: v2.4-dev19~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8454f2dbbc0bf4d9e307e9a0269a3de7413fd49a;p=thirdparty%2Fhaproxy.git MINOR: mux-h1: Subscribe for sends if output buffer is not empty in h1_snd_pipe 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. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 9e4088780d..a1cf3f9d41 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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; }