BUG/MAJOR: threads/checks: add 4 missing spin_unlock() in various functions
Some unlocks were missing, resulting in deadlocks even with a single thread.
We really need to make these functions safer by getting rid of all those
remaining "return" calls and only leave using a goto!
diff --git a/src/checks.c b/src/checks.c
index b679d2f..3c2eeb6 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -716,8 +716,10 @@
if (unlikely(check->result == CHK_RES_FAILED))
goto out_wakeup;
- if (conn->flags & CO_FL_HANDSHAKE)
+ if (conn->flags & CO_FL_HANDSHAKE) {
+ SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
return;
+ }
if (retrieve_errno_from_socket(conn)) {
chk_report_conn_err(check, errno, 0);
@@ -739,8 +741,10 @@
goto out_wakeup;
/* wake() will take care of calling tcpcheck_main() */
- if (check->type == PR_O2_TCPCHK_CHK)
+ if (check->type == PR_O2_TCPCHK_CHK) {
+ SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
return;
+ }
if (check->bo->o) {
conn->mux->snd_buf(cs, check->bo, 0);
@@ -2136,6 +2140,7 @@
switch (ret) {
case SF_ERR_UP:
+ SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
return t;
case SF_ERR_NONE:
/* we allow up to min(inter, timeout.connect) for a connection
@@ -2848,6 +2853,7 @@
if (s->proxy->timeout.check)
t->expire = tick_first(t->expire, t_con);
}
+ SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
return retcode;
}