From 8454f2dbbc0bf4d9e307e9a0269a3de7413fd49a Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 6 Apr 2021 17:27:32 +0200 Subject: [PATCH] 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. --- src/mux_h1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 9e4088780..a1cf3f9d4 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; }