BUG/MEDIUM: mux-fcgi: Try to fully fill demux buffer on receive if not empty
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2025 15:07:00 +0000 (16:07 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 30 Apr 2025 18:16:35 +0000 (20:16 +0200)
Don't reserve space for the HTX overhead on receive if the demux buffer is
not empty. Otherwise, the demux buffer may be erroneously reported as full
and this may block records processing. Because of this bug, a ping-pong loop
till timeout between data reception and demux process can be observed.

This bug was introduced by the commit 5f927f603 ("BUG/MEDIUM: mux-fcgi:
Properly handle read0 on partial records"). To fix the issue, if the demux
buffer is not empty when we try to receive more data, all free space in the
buffer can now be used. However, if the demux buffer is empty, we still try
to keep it aligned with the HTX.

This patch must be backported to 3.1.

(cherry picked from commit 0e08252294d5a7389ad42b51b4b931fab2e66f31)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cc4981548b12e3162fc020be02917f8462f00866)
[cf: This commit must be backported with the commit above]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/mux_fcgi.c

index 3693595..8177b05 100644 (file)
@@ -2791,7 +2791,7 @@ static int fcgi_recv(struct fcgi_conn *fconn)
                buf->head = sizeof(struct htx) - (fconn->state == FCGI_CS_RECORD_H ? FCGI_RECORD_HEADER_SZ : 0);
        }
        else
-               max = buf_room_for_htx_data(buf);
+               max = b_room(buf);
 
        ret = max ? conn->xprt->rcv_buf(conn, conn->xprt_ctx, buf, max, 0) : 0;