BUG/MEDIUM: leastconn: Don't try to reposition if the server is down

It may happen that the server is going down, and fwlc_srv_reposition()
is still called, because streams still attached to the server are
being terminated.
So in fwlc_srv_reposition(), just do nothing if we've been removed from
the tree.

This should fix github issue #2919.

This should not be backported, unless commit
9fe72bba3cf3484577fa1ef00723de08df757996 is also backported.

This commit is contained in:
Olivier Houchard 2025-04-02 10:40:42 +00:00 committed by Olivier Houchard
parent 4ec5509541
commit f59297e492

View File

@ -330,6 +330,15 @@ static void fwlc_srv_reposition(struct server *s)
return;
}
/*
* We're not in the tree, the server is probably down, don't
* do anything.
*/
if (unlikely(!s->tree_elt)) {
HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
_HA_ATOMIC_STORE(&s->lb_lock, 0);
return;
}
node = eb32_lookup(s->lb_tree, new_key);
if (node)
tree_elt = container_of(node, struct fwlc_tree_elt, lb_node);
@ -462,8 +471,7 @@ static void fwlc_srv_reposition(struct server *s)
__ha_barrier_store();
if (s->tree_elt)
_HA_ATOMIC_DEC(&s->tree_elt->elements);
_HA_ATOMIC_DEC(&s->tree_elt->elements);
/*
* Now lock the existing element, and its target list.