From 913b2d6c83b7b4c7a35b2cef479eb3ab1a471a01 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Tue, 3 Jun 2025 02:37:26 +0000 Subject: [PATCH] BUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock In fwlc_srv_reposition(), set the server's tree_elt while we still hold the lbprm read lock. While it was protected from concurrent fwlc_srv_reposition() calls by the server's lb_lock, it was not from dequeuing/requeuing that could occur if the server gets down/up or its weight is changed, and that would lead to inconsistencies, and the watchdog killing the process because it is stuck in an infinite loop in fwlc_get_next_server(). This hopefully fixes github issue #2990. This should be backported to 3.2. --- src/lb_fwlc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 10ad147b5..a082505e3 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -496,10 +496,10 @@ static void fwlc_srv_reposition(struct server *s) */ mt_list_unlock_full(&s->lb_mt_list, list); - HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); - s->tree_elt = tree_elt; + HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); + if (allocated_elt) s->free_elt = allocated_elt;