]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h2: remove conn from session on detach
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 14 Oct 2020 16:17:10 +0000 (18:17 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 15 Oct 2020 13:19:34 +0000 (15:19 +0200)
H2 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_h2.c

index 80a3e455e811594f37932dbed57bbef32554f033..545bb38475be353249fabb19892838ca850c7087 100644 (file)
@@ -3975,6 +3975,14 @@ static void h2_detach(struct conn_stream *cs)
                        }
                        else {
                                if (eb_is_empty(&h2c->streams_by_id)) {
+                                       /* If the connection is owned by the session, first remove it
+                                        * from its list
+                                        */
+                                       if (h2c->conn->owner) {
+                                               session_unown_conn(h2c->conn->owner, h2c->conn);
+                                               h2c->conn->owner = NULL;
+                                       }
+
                                        if (!srv_add_to_idle_list(objt_server(h2c->conn->target), h2c->conn, 1)) {
                                                /* The server doesn't want it, let's kill the connection right away */
                                                h2c->conn->mux->destroy(h2c);
@@ -3990,7 +3998,8 @@ static void h2_detach(struct conn_stream *cs)
 
                                }
                                else if (MT_LIST_ISEMPTY(&h2c->conn->list) &&
-                                        h2_avail_streams(h2c->conn) > 0 && objt_server(h2c->conn->target)) {
+                                        h2_avail_streams(h2c->conn) > 0 && objt_server(h2c->conn->target) &&
+                                        !LIST_ADDED(&h2c->conn->session_list)) {
                                        LIST_ADD(&__objt_server(h2c->conn->target)->available_conns[tid], mt_list_to_list(&h2c->conn->list));
                                }
                        }