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 <cfaulet@haproxy.com>
(cherry picked from commit ad1d5b58a7341fa7fe793dac4de461d4f5918582)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cc20000a0674e32f14a1123f812aae3bfd42cf0a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9758b0cf9519e7d8bc80066944ccf42689f7b483)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/backend.c b/src/backend.c
index dc13d3a..ad5692c 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1365,7 +1365,7 @@
 				// 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 = LIST_POP_LOCKED(&srv->idle_orphan_conns[i],
 				    struct connection *, list);
 				if (tokill_conn) {
@@ -1374,10 +1374,10 @@
 					LIST_ADDQ_LOCKED(&toremove_connections[i],
 					    &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]);
 			}
 		}