]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: leastconn: Unlock the write lock on allocation failure
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 1 Jun 2026 13:52:21 +0000 (15:52 +0200)
committerOlivier Houchard <cognet@ci0.org>
Mon, 1 Jun 2026 14:08:45 +0000 (16:08 +0200)
When we fail to allocate a new tree element, we're still holding the
write lock, so we should do an write unlock, not a read unlock, or the
lock will get corrupted and most likely this will end in a deadlock.

This should be backported up to 3.2.

src/lb_fwlc.c

index 6657d4c1e70cb6733ad7aadad19cad79e5913f22..6c1cd13e0891c81a761195d03872c0d4c3ea0ec7 100644 (file)
@@ -437,7 +437,7 @@ static void fwlc_srv_reposition(struct server *s)
                tree_elt = fwlc_alloc_tree_elt(s->proxy, allocated_elt);
                if (tree_elt == NULL) {
                        /* We failed to allocate memory, just try again later */
-                       HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
+                       HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
                        _HA_ATOMIC_STORE(&s->lb_lock, 0);
                        if (s->requeue_tasklet)
                                tasklet_wakeup(s->requeue_tasklet);