BUG/MINOR: mux-h1: Fix the splicing in TUNNEL mode
In the commit 17ccd1a35 ("BUG/MEDIUM: connection: add a mux flag to indicate
splice usability"), The CS_FL_MAY_SPLICE flags was added to notify the upper
layer that the mux is able to use the splicing. But this was only done for the
payload in a message, in HTTP_MSG_DATA state. But the splicing is also possible
in TUNNEL mode, in HTTP_MSG_TUNNEL state. In addition, the splicing ability is
always disabled for chunked messages.
This patch must be backported to 2.1 and 2.0.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 1a166a4..a6dffeb 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -1281,7 +1281,8 @@
goto end;
}
- if (h1m->state == H1_MSG_DATA && h1m->curr_len && h1s->cs)
+ if (h1s->cs && !(h1m->flags & H1_MF_CHNK) &&
+ ((h1m->state == H1_MSG_DATA && h1m->curr_len) || (h1m->state == H1_MSG_TUNNEL)))
h1s->cs->flags |= CS_FL_MAY_SPLICE;
else if (h1s->cs)
h1s->cs->flags &= ~CS_FL_MAY_SPLICE;
@@ -2681,7 +2682,7 @@
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)) {
+ if (h1m->state == H1_MSG_TUNNEL || (h1m->state == H1_MSG_DATA && h1m->curr_len)) {
h1s->flags |= H1S_F_BUF_FLUSH;
TRACE_STATE("flush stream's buffer", H1_EV_STRM_RECV, h1c->conn, h1s);
}
@@ -2798,7 +2799,8 @@
TRACE_STATE("read0 on connection", H1_EV_STRM_RECV, cs->conn, h1s);
}
- if (h1m->state != H1_MSG_DATA || !h1m->curr_len)
+ if ((h1m->state != H1_MSG_TUNNEL && h1m->state != H1_MSG_DATA) ||
+ (h1m->state == H1_MSG_DATA && !h1m->curr_len))
cs->flags &= ~CS_FL_MAY_SPLICE;
TRACE_LEAVE(H1_EV_STRM_RECV, cs->conn, h1s);