From 7aae858001f99dd4a80e3f533284cda5702d501a Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 6 Dec 2019 15:59:05 +0100 Subject: [PATCH] BUG/MINOR: mux-h1: Be sure to set CS_FL_WANT_ROOM when EOM can't be added 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index f09159413..b44204845 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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) &&