]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: backend: only update server's counters when the server exists
authorWilly Tarreau <w@1wt.eu>
Sat, 15 Dec 2018 14:11:36 +0000 (15:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 15 Dec 2018 14:13:10 +0000 (15:13 +0100)
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.

src/backend.c

index bb9b4ea665b65aa9a1f368d11767fac15d027f15..e11675756d390114dbdf9c00b8a4721ffeaab985 100644 (file)
@@ -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);