]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-fcgi: Don't request more room if mux is waiting for more data
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 11 May 2023 09:33:05 +0000 (11:33 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 11 May 2023 13:37:04 +0000 (15:37 +0200)
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

index f41578c76b9de724edfc2fba46494524254b1ec1..a5a1924025ac05e9b532091a2d151d5470c57177 100644 (file)
@@ -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)) {