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.
This commit is contained in:
Christopher Faulet 2020-07-03 14:51:15 +02:00
parent b4174d5a79
commit 2eaf30955f

View File

@ -1281,7 +1281,8 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx **htx
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 @@ static size_t h1_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
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 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c
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);