Skip to content

Commit c0aa9f0

Browse files
Olivier Houchardcognet
authored andcommitted
BUG/MEDIUM: leastconn: Unlock the write lock on allocation failure
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.
1 parent 4a540a4 commit c0aa9f0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/lb_fwlc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static void fwlc_srv_reposition(struct server *s)
437437
tree_elt = fwlc_alloc_tree_elt(s->proxy, allocated_elt);
438438
if (tree_elt == NULL) {
439439
/* We failed to allocate memory, just try again later */
440-
HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
440+
HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
441441
_HA_ATOMIC_STORE(&s->lb_lock, 0);
442442
if (s->requeue_tasklet)
443443
tasklet_wakeup(s->requeue_tasklet);

0 commit comments

Comments
 (0)