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.
(cherry picked from commit 2eaf30955f3619e2f262ba948313b8c2cb40ee81)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cfb54329854ee8302fea64f2181e3d2fa6c9acb1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/mux_h1.c b/src/mux_h1.c
index a868653..51a95b7 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -1383,7 +1383,8 @@
return 0;
}
- 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;
@@ -2477,7 +2478,7 @@
if (flags & CO_RFL_BUF_FLUSH) {
struct h1m *h1m = (!conn_is_back(cs->conn) ? &h1s->req : &h1s->res);
- 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;
}
else if (ret > 0 || (h1s->flags & H1S_F_SPLICED_DATA)) {
@@ -2556,7 +2557,8 @@
h1s->flags &= ~(H1S_F_BUF_FLUSH|H1S_F_SPLICED_DATA);
}
- 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;
return ret;