]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Be sure to set CS_FL_WANT_ROOM when EOM can't be added
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Dec 2019 14:59:05 +0000 (15:59 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 9 Dec 2019 08:30:50 +0000 (09:30 +0100)
During the message parsing, when the HTX buffer is full and only the HTX EOM
block cannot be added, it is important to notify the conn-stream that some
processing must still be done but it is blocked because there is not enough room
in the buffer. The way to do so is to set the CS_FL_WANT_ROOM flag on the
conn-stream. Otherwise, because all data are received and consumed, the mux is
not called anymore to add this last block, leaving the message unfinished from
the HAProxy point of view. The only way to unblock it is to receive a shutdown
for reads or to hit a timeout.

This patch must be backported to 2.1 and 2.0. The 1.9 does not seem to be
affected.

src/mux_h1.c

index f091594131c31002ce1139d25e77495c11c93d6b..b44204845465bbea73caca44b55706ed194e7972 100644 (file)
@@ -1279,9 +1279,14 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx **htx
 
   end:
        if (h1m->state == H1_MSG_DONE) {
+               h1s->flags &= ~H1S_F_APPEND_EOM;
                h1s->cs->flags |= CS_FL_EOI;
                TRACE_STATE("end of message", H1_EV_RX_DATA|H1_EV_RX_BODY|H1_EV_RX_EOI, h1s->h1c->conn);
        }
+       else if (h1m->state == H1_MSG_DATA && (h1m->flags & H1_MF_XFER_LEN) && h1m->curr_len == 0) {
+               h1s->flags |= H1S_F_APPEND_EOM;
+               TRACE_STATE("add append_eom", H1_EV_RX_DATA, h1s->h1c->conn);
+       }
 
        TRACE_LEAVE(H1_EV_RX_DATA|H1_EV_RX_BODY, h1s->h1c->conn, h1s,, (size_t[]){ret});
        return ret;
@@ -1473,7 +1478,8 @@ static size_t h1_process_input(struct h1c *h1c, struct buffer *buf, size_t count
 
        if (!b_data(&h1c->ibuf))
                h1_release_buf(h1c, &h1c->ibuf);
-       else if (h1s_data_pending(h1s) && !htx_is_empty(htx))
+
+       if ((h1s_data_pending(h1s) && !htx_is_empty(htx)) || (h1s->flags & H1S_F_APPEND_EOM))
                h1s->cs->flags |= CS_FL_RCV_MORE | CS_FL_WANT_ROOM;
 
        if (((h1s->flags & (H1S_F_REOS|H1S_F_APPEND_EOM)) == H1S_F_REOS) &&