]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: add a BUG_ON() to detect destroying connection in idle list
authorOlivier Houchard <cognet@ci0.org>
Tue, 24 Jan 2023 22:59:32 +0000 (23:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Jan 2023 14:30:49 +0000 (15:30 +0100)
Add a BUG_ON() in conn_free(), to check that when we're freeing a
connection, it is not still in the idle connections tree, otherwise the
next thread that will try to use it will probably crash.

src/connection.c

index 4a73dbcc802afb6a7fa6110b1d018cdb0aecfd82..97619ec260cebf929810be71de5b55ffe8ade128 100644 (file)
@@ -498,6 +498,10 @@ void conn_free(struct connection *conn)
        pool_free(pool_head_uniqueid, istptr(conn->proxy_unique_id));
        conn->proxy_unique_id = IST_NULL;
 
+       /* Make sure the connection is not left in the idle connection tree */
+       if (conn->hash_node != NULL)
+               BUG_ON(conn->hash_node->node.node.leaf_p != NULL);
+
        pool_free(pool_head_conn_hash_node, conn->hash_node);
        conn->hash_node = NULL;