BUG/MINOR: srv: do not init address if backend is disabled
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 6 Jan 2021 13:28:50 +0000 (14:28 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Jan 2021 10:44:49 +0000 (11:44 +0100)
Do not proceed on init_addr if the backend of the server is marked as
disabled. When marked as disabled, the server is not fully initialized
and some operation must be avoided to prevent segfault. It is correct
because there is no way to activate a disabled backend.

This fixes the github issue #1031.
This should be backported to 2.2.

(cherry picked from commit e3c419296211f08209300b9a06dc17467a6cb315)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 96a4ff137c88294b1d12bcb0d76f18bc1f2b41a6)
[cf: In fact this one should be backported in all stable versions]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 94c6b618d2aa64587c39cd201d6336516910ce8f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/server.c

index 25f30ce..801bb82 100644 (file)
@@ -4439,7 +4439,7 @@ int srv_init_addr(void)
                struct server *srv;
 
                /* servers are in backend only */
-               if (!(curproxy->cap & PR_CAP_BE))
+               if (!(curproxy->cap & PR_CAP_BE) || curproxy->state == PR_STSTOPPED)
                        goto srv_init_addr_next;
 
                for (srv = curproxy->srv; srv; srv = srv->next)