From 9758b0cf9519e7d8bc80066944ccf42689f7b483 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 28 Jan 2021 10:16:29 +0100 Subject: [PATCH] BUG/MINOR: backend: hold correctly lock when killing idle conn The wrong lock seems to be held when trying to remove another thread connection if max fd limit has been reached (locking the current thread instead of the target thread lock). This could be backported up to 2.0. (cherry picked from commit a3bf62ec541479531ebe93bde46b436cb95c9a87) Signed-off-by: Christopher Faulet (cherry picked from commit ad1d5b58a7341fa7fe793dac4de461d4f5918582) Signed-off-by: Christopher Faulet (cherry picked from commit cc20000a0674e32f14a1123f812aae3bfd42cf0a) Signed-off-by: Christopher Faulet --- src/backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend.c b/src/backend.c index e0b9cc5..53a2464 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1303,7 +1303,7 @@ int connect_server(struct stream *s) // see it possibly larger. ALREADY_CHECKED(i); - HA_SPIN_LOCK(OTHER_LOCK, &toremove_lock[tid]); + HA_SPIN_LOCK(OTHER_LOCK, &toremove_lock[i]); tokill_conn = MT_LIST_POP(&srv->idle_orphan_conns[i], struct connection *, list); if (tokill_conn) { @@ -1312,10 +1312,10 @@ int connect_server(struct stream *s) MT_LIST_ADDQ(&toremove_connections[i], (struct mt_list *)&tokill_conn->list); task_wakeup(idle_conn_cleanup[i], TASK_WOKEN_OTHER); - HA_SPIN_UNLOCK(OTHER_LOCK, &toremove_lock[tid]); + HA_SPIN_UNLOCK(OTHER_LOCK, &toremove_lock[i]); break; } - HA_SPIN_UNLOCK(OTHER_LOCK, &toremove_lock[tid]); + HA_SPIN_UNLOCK(OTHER_LOCK, &toremove_lock[i]); } } -- 1.7.10.4