From: Willy Tarreau Date: Sat, 15 Dec 2018 14:11:36 +0000 (+0100) Subject: BUG/MAJOR: backend: only update server's counters when the server exists X-Git-Tag: v1.9-dev11~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cc79ed28f6d6931a3c87c0d3ab397b8dae20bbbd;p=thirdparty%2Fhaproxy.git BUG/MAJOR: backend: only update server's counters when the server exists PiBa-NL reported that since this commit f157384 ("MINOR: backend: count the number of connect and reuse per server and per backend"), reg-test connection/h00001 fails. Indeed it does, the server is not checked for existing prior to updating its counter. It should also fail with transparent mode. --- diff --git a/src/backend.c b/src/backend.c index bb9b4ea665..e11675756d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1378,10 +1378,12 @@ int connect_server(struct stream *s) if (s->flags & SF_SRV_REUSED) { HA_ATOMIC_ADD(&s->be->be_counters.reuse, 1); - HA_ATOMIC_ADD(&srv->counters.reuse, 1); + if (srv) + HA_ATOMIC_ADD(&srv->counters.reuse, 1); } else { HA_ATOMIC_ADD(&s->be->be_counters.connect, 1); - HA_ATOMIC_ADD(&srv->counters.connect, 1); + if (srv) + HA_ATOMIC_ADD(&srv->counters.connect, 1); } err = si_connect(&s->si[1], srv_conn);