From 89cc83287a6c9536fa14243397ed1038192eb8de Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 3 Jul 2020 15:08:49 +0200 Subject: [PATCH] MINOR: mux-h1: Improve traces about the splicing Trace messages have been added when the CS_FL_MAY_SPLICE flag is set or unset and when the splicing is really enabled for the H1 connection. This patch may be backpored to 2.1 to ease debugging. (cherry picked from commit 27182297c763fb6f4818c9872692df51d4032d6b) Signed-off-by: Christopher Faulet --- src/mux_h1.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index f3226ed..963f51e 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -489,8 +489,10 @@ static struct conn_stream *h1s_new_cs(struct h1s *h1s) if (h1s->flags & H1S_F_NOT_FIRST) cs->flags |= CS_FL_NOT_FIRST; - if (global.tune.options & GTUNE_USE_SPLICE) + 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) < 0) { TRACE_DEVEL("leaving on stream creation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1s->h1c->conn, h1s); @@ -1279,10 +1281,14 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx **htx } if (h1s->cs && !(h1m->flags & H1_MF_CHNK) && - ((h1m->state == H1_MSG_DATA && h1m->curr_len) || (h1m->state == H1_MSG_TUNNEL))) + ((h1m->state == H1_MSG_DATA && h1m->curr_len) || (h1m->state == H1_MSG_TUNNEL))) { + TRACE_STATE("notify the mux can use splicing", H1_EV_RX_DATA|H1_EV_RX_BODY, h1s->h1c->conn, h1s); h1s->cs->flags |= CS_FL_MAY_SPLICE; - else if (h1s->cs) + } + else if (h1s->cs) { + TRACE_STATE("notify the mux can't use splicing anymore", H1_EV_RX_DATA|H1_EV_RX_BODY, h1s->h1c->conn, h1s); h1s->cs->flags &= ~CS_FL_MAY_SPLICE; + } *ofs += ret; @@ -2713,9 +2719,11 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c goto end; } - h1s->flags &= ~H1S_F_BUF_FLUSH; - h1s->flags |= H1S_F_SPLICED_DATA; - TRACE_STATE("enable splicing", H1_EV_STRM_RECV, cs->conn, h1s); + if (!(h1s->flags & H1S_F_SPLICED_DATA)) { + h1s->flags &= ~H1S_F_BUF_FLUSH; + h1s->flags |= H1S_F_SPLICED_DATA; + TRACE_STATE("enable splicing", H1_EV_STRM_RECV, cs->conn, h1s); + } if (!h1_recv_allowed(h1s->h1c)) { TRACE_DEVEL("leaving on !recv_allowed", H1_EV_STRM_RECV, cs->conn, h1s); @@ -2742,10 +2750,12 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c if ((h1s->flags & H1S_F_REOS) || (h1m->state != H1_MSG_TUNNEL && h1m->state != H1_MSG_DATA) || - (h1m->state == H1_MSG_DATA && !h1m->curr_len)) + (h1m->state == H1_MSG_DATA && !h1m->curr_len)) { + TRACE_STATE("notify the mux can't use splicing anymore", H1_EV_STRM_RECV, h1s->h1c->conn, h1s); cs->flags &= ~CS_FL_MAY_SPLICE; + } - TRACE_LEAVE(H1_EV_STRM_RECV, cs->conn, h1s); + TRACE_LEAVE(H1_EV_STRM_RECV, cs->conn, h1s,, (size_t[]){ret}); return ret; } @@ -2768,7 +2778,7 @@ static int h1_snd_pipe(struct conn_stream *cs, struct pipe *pipe) } } - TRACE_LEAVE(H1_EV_STRM_SEND, cs->conn, h1s); + TRACE_LEAVE(H1_EV_STRM_SEND, cs->conn, h1s,, (size_t[]){ret}); return ret; } #endif -- 1.7.10.4