BUILD: leastconn: fix build warning when building without threads on old machines

Machines lacking CAS8B/DWCAS and emit a warning in lb_fwlc.c without
threads due to declaration ordering. Let's just move the variable
declaration into the block that uses it as a last variable. No
backport is needed.
This commit is contained in:
Willy Tarreau 2025-04-28 16:48:42 +02:00
parent 589d916efa
commit aa49965d4e

View File

@ -36,9 +36,6 @@ DECLARE_STATIC_POOL(pool_head_fwlc_elt, "fwlc_tree_elt", sizeof(struct fwlc_tree
*/
static int fwlc_set_seq_and_smallest(struct lbprm *lbprm, uint64_t current, unsigned int seq, unsigned int smallest)
{
#if !defined(HA_CAS_IS_8B) && !defined(HA_HAVE_CAS_DW)
__decl_thread(static HA_SPINLOCK_T seq_lock);
#endif
uint64_t dst_nb = seq | ((uint64_t)smallest << 32);
int ret;
#if defined(HA_CAS_IS_8B)
@ -46,6 +43,8 @@ static int fwlc_set_seq_and_smallest(struct lbprm *lbprm, uint64_t current, unsi
#elif defined(HA_HAVE_CAS_DW)
ret = _HA_ATOMIC_DWCAS(&lbprm->lb_seq, &current, &dst_nb);
#else
__decl_thread(static HA_SPINLOCK_T seq_lock);
HA_SPIN_LOCK(OTHER_LOCK, &seq_lock);
if (lbprm->lb_seq == current) {
lbprm->lb_seq = dst_nb;