From 2b861bf723841d921715961dba7eb4f4253e1cb0 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 6 Apr 2021 17:24:39 +0200 Subject: [PATCH] MINOR: mux-h1: clean up conditions to enabled and disabled splicing First, there is no reason to announce the splicing support at the conn-stream level when it is created, at least for now. GTUNE_USE_SPLICE option is already handled at the stream level. Second, in h1_rcv_buf(), there is no reason to test the message state to switch the H1C in splicing mode (via H1C_F_WANT_SPLICE flag). h1_process_input() already takes care to set CS_FL_MAY_SPLICE flag on the conn-stream when appropriate. Thus, in h1_rcv_buf(), we can rely on this flag to change the H1C state. Finally, if h1_rcv_pipe() is called, it means the H1C is already in the splicing mode. H1C_F_WANT_SPLICE flag is necessarily already set. Thus no reason to force it. --- src/mux_h1.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 89817df621..9e4088780d 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -586,11 +586,6 @@ static struct conn_stream *h1s_new_cs(struct h1s *h1s, struct buffer *input) if (h1s->flags & H1S_F_NOT_FIRST) cs->flags |= CS_FL_NOT_FIRST; - if (global.tune.options & GTUNE_USE_SPLICE) { - TRACE_STATE("notify the mux can use splicing", H1_EV_STRM_NEW, h1s->h1c->conn, h1s); - cs->flags |= CS_FL_MAY_SPLICE; - } - if (stream_create_from_cs(cs, input) < 0) { TRACE_DEVEL("leaving on stream creation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1s->h1c->conn, h1s); goto err; @@ -616,11 +611,6 @@ static struct conn_stream *h1s_upgrade_cs(struct h1s *h1s, struct buffer *input) goto err; } - if (global.tune.options & GTUNE_USE_SPLICE) { - TRACE_STATE("notify the mux can use splicing", H1_EV_STRM_NEW, h1s->h1c->conn, h1s); - h1s->cs->flags |= CS_FL_MAY_SPLICE; - } - h1s->h1c->flags |= H1C_F_ST_READY; TRACE_LEAVE(H1_EV_STRM_NEW, h1s->h1c->conn, h1s); return h1s->cs; @@ -3349,11 +3339,9 @@ static size_t h1_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun else TRACE_DEVEL("h1c ibuf not allocated", H1_EV_H1C_RECV|H1_EV_H1C_BLK, h1c->conn); - if (flags & CO_RFL_BUF_FLUSH) { - if (h1m->state == H1_MSG_TUNNEL || (h1m->state == H1_MSG_DATA && h1m->curr_len)) { - h1c->flags |= H1C_F_WANT_SPLICE; - TRACE_STATE("Block xprt rcv_buf to flush stream's buffer (want_splice)", H1_EV_STRM_RECV, h1c->conn, h1s); - } + if ((flags & CO_RFL_BUF_FLUSH) && (cs->flags & CS_FL_MAY_SPLICE)) { + h1c->flags |= H1C_F_WANT_SPLICE; + TRACE_STATE("Block xprt rcv_buf to flush stream's buffer (want_splice)", H1_EV_STRM_RECV, h1c->conn, h1s); } else { if (((flags & CO_RFL_KEEP_RECV) || (h1m->state != H1_MSG_DONE)) && !(h1c->wait_event.events & SUB_RETRY_RECV)) @@ -3451,10 +3439,6 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c goto end; } - if (!(h1c->flags & H1C_F_WANT_SPLICE)) { - h1c->flags |= H1C_F_WANT_SPLICE; - TRACE_STATE("Block xprt rcv_buf to perform splicing", H1_EV_STRM_RECV, cs->conn, h1s); - } if (h1s_data_pending(h1s)) { TRACE_STATE("flush input buffer before splicing", H1_EV_STRM_RECV, cs->conn, h1s); goto end; -- 2.39.5