From: Amaury Denoyelle Date: Tue, 24 Oct 2023 16:31:28 +0000 (+0200) Subject: BUG/MINOR: backend: fix wrong BUG_ON for avail conn X-Git-Tag: v2.9-dev9~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9fbbaf2a88f775f73496c20e944b124292215e5;p=thirdparty%2Fhaproxy.git BUG/MINOR: backend: fix wrong BUG_ON for avail conn Idle connections are both stored in an idle/safe tree and in an idle list. The list is used as a secondary storage to be able to retrieve them by usage order. If a connection is moved into the available tree, it must not be present in the idle list. A BUG_ON() was written to check this but was placed at the wrong code section. Fix this by removing the misplaced one and write new ones for avail_conns tree insertion and lookup. The impact of this bug is minor as the misplaced BUG_ON() did not seem to be triggered. No need to backport. --- diff --git a/src/backend.c b/src/backend.c index 28862f7753..c6317bb261 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1457,6 +1457,9 @@ static int connect_server(struct stream *s) if (!eb_is_empty(&srv->per_thr[tid].avail_conns)) { srv_conn = srv_lookup_conn(&srv->per_thr[tid].avail_conns, hash); if (srv_conn) { + /* connection cannot be in idle list if used as an avail idle conn. */ + BUG_ON(LIST_INLIST(&srv_conn->idle_list)); + DBG_TRACE_STATE("reuse connection from avail", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); reuse = 1; } @@ -1564,9 +1567,6 @@ static int connect_server(struct stream *s) int avail = srv_conn->mux->avail_streams(srv_conn); if (avail <= 1) { - /* connection cannot be in idle list if used as an avail idle conn. */ - BUG_ON(LIST_INLIST(&srv_conn->idle_list)); - /* No more streams available, remove it from the list */ HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); conn_delete_from_tree(srv_conn);