MEDIUM: fcgi: remove conn from session on detach
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 14 Oct 2020 16:17:11 +0000 (18:17 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 15 Oct 2020 13:19:34 +0000 (15:19 +0200)
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

index 7dd07ba..46c77cb 100644 (file)
@@ -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));
                        }
                }