]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Fix the splicing in TUNNEL mode
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 3 Jul 2020 12:51:15 +0000 (14:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 Jul 2020 12:29:18 +0000 (14:29 +0200)
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.

src/mux_h1.c

index 1a166a4ebfb9dff935d2c919e671621b86ffa50f..a6dffeb09daaea2f10e18754ef06a0980ce2c82b 100644 (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);