From: Amaury Denoyelle Date: Fri, 19 Feb 2021 14:37:38 +0000 (+0100) Subject: MINOR: mux_h2: do not try to remove front conn from idle trees X-Git-Tag: v2.4-dev9~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d752a8f97f391b8e6f97c3301442b3ebda38c72;p=thirdparty%2Fhaproxy.git MINOR: mux_h2: do not try to remove front conn from idle trees In h2_process there was two parts where the connection was removed from the idle trees, without first checking if the connection is a backend side. This should not produce a crash as the node is properly zeroed on conn_init. However, it is better to explicit the test as it is done on all other places. Besides it will be mandatory if the node part is dynamically allocated only for backend connections. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index c94615949d..a6c167b568 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3904,15 +3904,19 @@ static int h2_process(struct h2c *h2c) } /* connections in error must be removed from the idle lists */ - HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); - conn_delete_from_tree(&conn->hash_node); - HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + if (conn->flags & CO_FL_LIST_MASK) { + HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + conn_delete_from_tree(&conn->hash_node); + HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + } } else if (h2c->st0 == H2_CS_ERROR) { /* connections in error must be removed from the idle lists */ - HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); - conn_delete_from_tree(&conn->hash_node); - HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + if (conn->flags & CO_FL_LIST_MASK) { + HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + conn_delete_from_tree(&conn->hash_node); + HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + } } if (!b_data(&h2c->dbuf)) @@ -4049,9 +4053,11 @@ do_leave: } /* in any case this connection must not be considered idle anymore */ - HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); - conn_delete_from_tree(&h2c->conn->hash_node); - HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + if (h2c->conn->flags & CO_FL_LIST_MASK) { + HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + conn_delete_from_tree(&h2c->conn->hash_node); + HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); + } /* either we can release everything now or it will be done later once * the last stream closes.