]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: checks: make sure the warmup task takes the server lock
authorWilly Tarreau <w@1wt.eu>
Sun, 5 May 2019 04:54:22 +0000 (06:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 5 May 2019 04:54:22 +0000 (06:54 +0200)
The server warmup task is used when a server uses the "slowstart"
parameter. This task affects the server's weight and maxconn, and may
dequeue pending connections from the queue. This must be done under
the server's lock, which was not the case.

This must be backported to 1.9 and 1.8.

src/checks.c

index 76bd8e3df45b5a8a467c9fb174524331b9f2ec19..aeb3b79b66a4d31139f64cdb911eed71983300bc 100644 (file)
@@ -1488,12 +1488,16 @@ static struct task *server_warmup(struct task *t, void *context, unsigned short
            (s->next_state != SRV_ST_STARTING))
                return t;
 
+       HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
+
        /* recalculate the weights and update the state */
        server_recalc_eweight(s, 1);
 
        /* probably that we can refill this server with a bit more connections */
        pendconn_grab_from_px(s);
 
+       HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
+
        /* get back there in 1 second or 1/20th of the slowstart interval,
         * whichever is greater, resulting in small 5% steps.
         */