packages/net/haproxy/patches/002-BUG-MEDIUM-connections-Hold-the-lock-when-wanting-to-kill-a-connection.patch
Christian Lachner fdaa55a918 haproxy: Update HAProxy to v2.1.2
- Major version jump from v2.0 to v2.1
- Update haproxy download URL and hash
- Add new patches (see https://www.haproxy.org/bugs/bugs-2.1.2.html)
- Stop building LUA 5.3 in the haproxy build-process and use liblua5.3 as a dependency instead

Signed-off-by: Christian Lachner <gladiac@gmail.com>
2020-02-03 07:54:31 +01:00

37 lines
1.3 KiB
Diff

commit 000f227a4cfdb019575e889638f9e0e5a53bbb0b
Author: Olivier Houchard <cognet@ci0.org>
Date: Mon Dec 30 18:15:40 2019 +0100
BUG/MEDIUM: connections: Hold the lock when wanting to kill a connection.
In connect_server(), when we decide we want to kill the connection of
another thread because there are too many idle connections, hold the
toremove_lock of the corresponding thread, othervise, there's a small race
condition where we could try to add the connection to the toremove_connections
list while it has already been free'd.
This should be backported to 2.0 and 2.1.
(cherry picked from commit 140237471e408736bb7162e68c572c710a66a526)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/backend.c b/src/backend.c
index ebc5050cb..be081a5e1 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1295,6 +1295,7 @@ int connect_server(struct stream *s)
// see it possibly larger.
ALREADY_CHECKED(i);
+ HA_SPIN_LOCK(OTHER_LOCK, &toremove_lock[tid]);
tokill_conn = MT_LIST_POP(&srv->idle_orphan_conns[i],
struct connection *, list);
if (tokill_conn) {
@@ -1305,6 +1306,7 @@ int connect_server(struct stream *s)
task_wakeup(idle_conn_cleanup[i], TASK_WOKEN_OTHER);
break;
}
+ HA_SPIN_UNLOCK(OTHER_LOCK, &toremove_lock[tid]);
}
}