From: Christopher Faulet Date: Fri, 6 Nov 2026 09:49:35 +0000 (+0100) Subject: MINOR: mux-fcgi: don't add a closed connection to an idle list on detach X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=2acf116bfa075dd4722801df47cd45a9a0866beb;p=haproxy.git MINOR: mux-fcgi: don't add a closed connection to an idle list on detach In fcgi_detach(), the test deciding whether the connection may be moved to an idle list checks FCGI_CF_EOS, FCGI_CF_ERR_PENDING, FCGI_CF_ERROR and FCGI_CF_KEEP_CONN, but not the connection state. A connection that already switched to FCGI_CS_CLOSED may thus be inserted in the session server list or in the server's idle pool, while fcgi_avail_streams() reports no available stream for it. The stream immediately before, in the same function, does test FCGI_CS_CLOSED. This can currently only happen with a private connection, since srv_add_to_idle_list() already rejects connections without available streams, and it is not harmful either way: session_get_conn() also requires an available stream, so such a connection is never reused. But it is still wrong to park it, since it prevents the session from dropping it and forces a useless idle counter increment. Note that fcgi_conn_is_dead() must not be used here: it also requires FCGI_CF_KEEP_CONN to be cleared or FCGI_CF_ERROR to be set, so it does not cover every FCGI_CS_CLOSED connection, and the non-private branch below clears conn->owner before parking the connection. This may be backported to all supported versions. --- diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index c471e2a76..028792e34 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -3859,6 +3859,7 @@ static void fcgi_detach(struct sedesc *sd) fcgi_conn_update_timeout(fconn); if (!(fconn->flags & (FCGI_CF_EOS|FCGI_CF_ERR_PENDING|FCGI_CF_ERROR)) && + (fconn->state != FCGI_CS_CLOSED) && (fconn->flags & FCGI_CF_KEEP_CONN)) { if (fconn->conn->flags & CO_FL_PRIVATE) { /* Add the connection in the session serverlist, if not already done */