From 46f041d7f87ca93576abcf2501abdc11a31b6a1a Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 14 Oct 2020 18:17:11 +0200 Subject: [PATCH] MEDIUM: fcgi: remove conn from session on detach FCGI mux is marked with HOL blocking. On safe reuse mode, the connection using it are placed on the sessions instead of the available lists to avoid sharing it with several clients. On detach, if they are no more streams, remove the connection from the session before adding it to the idle list. If there is still used streams, do not add it to available list as it should be already on the session list. --- src/mux_fcgi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 7dd07ba311..46c77cb8fe 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -3578,6 +3578,14 @@ static void fcgi_detach(struct conn_stream *cs) } else { if (eb_is_empty(&fconn->streams_by_id)) { + /* If the connection is owned by the session, first remove it + * from its list + */ + if (fconn->conn->owner) { + session_unown_conn(fconn->conn->owner, fconn->conn); + fconn->conn->owner = NULL; + } + if (!srv_add_to_idle_list(objt_server(fconn->conn->target), fconn->conn, 1)) { /* The server doesn't want it, let's kill the connection right away */ fconn->conn->mux->destroy(fconn); @@ -3592,7 +3600,8 @@ static void fcgi_detach(struct conn_stream *cs) return; } else if (MT_LIST_ISEMPTY(&fconn->conn->list) && - fcgi_avail_streams(fconn->conn) > 0 && objt_server(fconn->conn->target)) { + fcgi_avail_streams(fconn->conn) > 0 && objt_server(fconn->conn->target) && + !LIST_ADDED(&fconn->conn->session_list)) { LIST_ADD(&__objt_server(fconn->conn->target)->available_conns[tid], mt_list_to_list(&fconn->conn->list)); } } -- 2.47.3