]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: tcp-check: Don't lock the server in tcpcheck_main
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Nov 2017 09:06:29 +0000 (10:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 Nov 2017 09:43:23 +0000 (10:43 +0100)
There was a deadlock in tcpcheck_main function. The server's lock was already
acquired by the caller (process_chk_conn or wake_srv_chk).

This patch must be backported in 1.8.

src/checks.c

index ad25ac094f989fd8face582ce082f83d502ca48a..63747201e15946eb911fd034653586490ec845e0 100644 (file)
@@ -2595,8 +2595,6 @@ static int tcpcheck_main(struct check *check)
        struct list *head = check->tcpcheck_rules;
        int retcode = 0;
 
-       HA_SPIN_LOCK(SERVER_LOCK, &check->server->lock);
-
        /* here, we know that the check is complete or that it failed */
        if (check->result != CHK_RES_UNKNOWN)
                goto out_end_tcpcheck;
@@ -2637,7 +2635,7 @@ static int tcpcheck_main(struct check *check)
                        if (s->proxy->timeout.check)
                                t->expire = tick_first(t->expire, t_con);
                }
-               goto out_unlock;
+               goto out;
        }
 
        /* special case: option tcp-check with no rule, a connect is enough */
@@ -2732,7 +2730,7 @@ static int tcpcheck_main(struct check *check)
                                        chunk_appendf(&trash, " comment: '%s'", comment);
                                set_server_check_status(check, HCHK_STATUS_SOCKERR, trash.str);
                                check->current_step = NULL;
-                               goto out_unlock;
+                               goto out;
                        }
 
                        if (check->cs)
@@ -2854,7 +2852,7 @@ static int tcpcheck_main(struct check *check)
                                        if (s->proxy->timeout.check)
                                                t->expire = tick_first(t->expire, t_con);
                                }
-                               goto out_unlock;
+                               goto out;
                        }
 
                } /* end 'connect' */
@@ -3059,7 +3057,7 @@ static int tcpcheck_main(struct check *check)
        if (&check->current_step->list != head &&
            check->current_step->action == TCPCHK_ACT_EXPECT)
                __cs_want_recv(cs);
-       goto out_unlock;
+       goto out;
 
  out_end_tcpcheck:
        /* collect possible new errors */
@@ -3074,8 +3072,7 @@ static int tcpcheck_main(struct check *check)
 
        __cs_stop_both(cs);
 
- out_unlock:
-       HA_SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
+ out:
        return retcode;
 }