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.

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);
__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.