]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: backend: nbsrv() should return 0 if backend is disabled
authorMarcin Deranek <marcin.deranek@booking.com>
Thu, 22 Dec 2016 15:21:08 +0000 (16:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2016 23:09:12 +0000 (00:09 +0100)
According to nbsrv() documentation this fetcher should return "an
integer value corresponding to the number of usable servers".
In case backend is disabled none of servers is usable, so I believe
fetcher should return 0.

This patch should be backported to 1.7, 1.6, 1.5.

src/backend.c

index 658212de4d6e015edd92a727fc576ed8b73a413f..3acb1daeb775c7c41ac68cb329b3ca1649b57c2b 100644 (file)
@@ -1607,7 +1607,9 @@ smp_fetch_nbsrv(const struct arg *args, struct sample *smp, const char *kw, void
        smp->data.type = SMP_T_SINT;
        px = args->data.prx;
 
-       if (px->srv_act)
+       if (px->state == PR_STSTOPPED)
+               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;