From: Olivier Houchard Date: Fri, 20 Nov 2026 14:33:44 +0000 (+0100) Subject: BUG/MEDIUM: mux-fcgi: let the buffer callback allocate despite the queue X-Git-Url: https://git.kaiwu.me/http/%7B@url%7D?a=commitdiff_plain;h=14495d1ed27e15b3350dc1e92640c3830c310eb2;p=haproxy.git BUG/MEDIUM: mux-fcgi: let the buffer callback allocate despite the queue fcgi_buf_available() is called by offer_buffers() while the fconn is still in the buffer wait queue. Since commit d1eb48a12 ("MEDIUM: dynbuf: refrain from offering a buffer if more critical ones are waiting"), b_alloc() refuses to allocate when the queue of the same or of a more critical level is not empty, unless DB_F_NOQUEUE is passed. As the fconn is queued with DB_MUX_RX, the demux buffer allocation always fails from the callback, and the connection remains blocked until it times out. This was reproduced by faking a failed demux buffer allocation when receiving the response: the request ends with a 504. Let's pass DB_F_NOQUEUE to the allocations made from the callback, as was done for mux-h2 in commit d7192a667 ("BUG/MEDIUM: mux-h2: permit the buffer callback to allocate despite the queue"). This was introduced in 3.0 by the commit above and must be backported to 3.0. --- diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index f3f4ef32c..ff7554ea0 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -516,14 +516,15 @@ static int fcgi_buf_available(void *target) struct fcgi_conn *fconn = target; struct fcgi_strm *fstrm; - if ((fconn->flags & FCGI_CF_DEM_DALLOC) && b_alloc(&fconn->dbuf, DB_MUX_RX)) { + /* we're still in the queue here, hence DB_F_NOQUEUE */ + if ((fconn->flags & FCGI_CF_DEM_DALLOC) && b_alloc(&fconn->dbuf, DB_MUX_RX | DB_F_NOQUEUE)) { TRACE_STATE("unblocking fconn, dbuf allocated", FCGI_EV_FCONN_RECV|FCGI_EV_FCONN_BLK|FCGI_EV_FCONN_WAKE, fconn->conn); fconn->flags &= ~FCGI_CF_DEM_DALLOC; fcgi_conn_restart_reading(fconn, 1); return 1; } - if ((fconn->flags & FCGI_CF_MUX_MALLOC) && b_alloc(br_tail(fconn->mbuf), DB_MUX_TX)) { + if ((fconn->flags & FCGI_CF_MUX_MALLOC) && b_alloc(br_tail(fconn->mbuf), DB_MUX_TX | DB_F_NOQUEUE)) { TRACE_STATE("unblocking fconn, mbuf allocated", FCGI_EV_FCONN_SEND|FCGI_EV_FCONN_BLK|FCGI_EV_FCONN_WAKE, fconn->conn); fconn->flags &= ~FCGI_CF_MUX_MALLOC; if (fconn->flags & FCGI_CF_DEM_MROOM) { @@ -535,7 +536,7 @@ static int fcgi_buf_available(void *target) if ((fconn->flags & FCGI_CF_DEM_SALLOC) && (fstrm = fcgi_conn_st_by_id(fconn, fconn->dsi)) && fcgi_strm_sc(fstrm) && - b_alloc(&fstrm->rxbuf, DB_SE_RX)) { + b_alloc(&fstrm->rxbuf, DB_SE_RX | DB_F_NOQUEUE)) { TRACE_STATE("unblocking fstrm, rxbuf allocated", FCGI_EV_STRM_RECV|FCGI_EV_FSTRM_BLK|FCGI_EV_STRM_WAKE, fconn->conn, fstrm); fconn->flags &= ~FCGI_CF_DEM_SALLOC; fcgi_conn_restart_reading(fconn, 1);