mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-30 07:06:42 +00:00
CLEANUP: Replace repeated code to count usable servers with be_usable_srv()
2 places were using an open-coded implementation of this function to count available servers. Note that the avg_queue_size() fetch didn't check that the proxy was in STOPPED state so it would possibly return a wrong server count here but that wouldn't impact the returned value. Signed-off-by: Nenad Merdanovic <nmerdan@haproxy.com>
This commit is contained in:
parent
b7e7c4720a
commit
2754fbcfd6
@ -1614,14 +1614,7 @@ smp_fetch_nbsrv(const struct arg *args, struct sample *smp, const char *kw, void
|
|||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
px = args->data.prx;
|
px = args->data.prx;
|
||||||
|
|
||||||
if (px->state == PR_STSTOPPED)
|
smp->data.u.sint = be_usable_srv(px);
|
||||||
smp->data.u.sint = 0;
|
|
||||||
else if (px->srv_act)
|
|
||||||
smp->data.u.sint = px->srv_act;
|
|
||||||
else if (px->lbprm.fbck)
|
|
||||||
smp->data.u.sint = 1;
|
|
||||||
else
|
|
||||||
smp->data.u.sint = px->srv_bck;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1780,12 +1773,7 @@ smp_fetch_avg_queue_size(const struct arg *args, struct sample *smp, const char
|
|||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
px = args->data.prx;
|
px = args->data.prx;
|
||||||
|
|
||||||
if (px->srv_act)
|
nbsrv = be_usable_srv(px);
|
||||||
nbsrv = px->srv_act;
|
|
||||||
else if (px->lbprm.fbck)
|
|
||||||
nbsrv = 1;
|
|
||||||
else
|
|
||||||
nbsrv = px->srv_bck;
|
|
||||||
|
|
||||||
if (nbsrv > 0)
|
if (nbsrv > 0)
|
||||||
smp->data.u.sint = (px->totpend + nbsrv - 1) / nbsrv;
|
smp->data.u.sint = (px->totpend + nbsrv - 1) / nbsrv;
|
||||||
|
Loading…
Reference in New Issue
Block a user