From efebff35bb958ba72850323696f88b2b4f6592f4 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 11 May 2023 11:33:05 +0200 Subject: [PATCH] BUG/MEDIUM: mux-fcgi: Don't request more room if mux is waiting for more data A mux must never report it is waiting for room in the channel buffer if this buffer is empty. Because there is nothing the application layer can do to unblock the situation. Indeed, when this happens, it means the mux is waiting for data to progress. It typically happens when all headers are not received. In the FCGI mux, if some data remain in the RX buffer but the channel buffer is empty, it does no longer report it is waiting for room. This patch should fix the issue #2150. It must be backported as far as 2.6. --- src/mux_fcgi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index f41578c76b..a5a1924025 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -3874,8 +3874,15 @@ static size_t fcgi_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, else TRACE_STATE("fstrm rxbuf not allocated", FCGI_EV_STRM_RECV|FCGI_EV_FSTRM_BLK, fconn->conn, fstrm); - if (b_data(&fstrm->rxbuf)) - se_fl_set(fstrm->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); + if (b_data(&fstrm->rxbuf)) { + /* If the channel buffer is not empty, consider the mux is + * blocked because it needs more room. But if the channel buffer + * is empty, it means partial data were received and the mux + * needs to receive more data to be able to parse it. + */ + if (b_data(buf)) + se_fl_set(fstrm->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); + } else { se_fl_clr(fstrm->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); if (fstrm->state == FCGI_SS_ERROR || (fstrm->h1m.state == H1_MSG_DONE)) { -- 2.47.3