]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: proxy: ignore stopped peers
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Sep 2015 14:27:44 +0000 (16:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Sep 2015 14:27:44 +0000 (16:27 +0200)
Since commit f83d3fe ("MEDIUM: init: stop any peers section not bound
to the correct process"), it is possible to stop unused peers on certain
processes. The problem is that the pause/resume/stop functions are not
aware of this and will pass a NULL proxy pointer to the respective
functions, resulting in segfaults in unbound processes during soft
restarts.

Properly check that the peers' frontend is still valid before calling
them.

This bug also affects 1.5 so the fix must be backported. Note that this
fix is not enough to completely get rid of the segfault, the next one
is needed as well.

src/proxy.c

index 52e4bbe52bcbdaee3744b0ab07a05c3aa384c91c..1f2fc56156974e729a9034ca3f4ed9c266670ef8 100644 (file)
@@ -937,7 +937,8 @@ void soft_stop(void)
 
        prs = peers;
        while (prs) {
-               stop_proxy((struct proxy *)prs->peers_fe);
+               if (prs->peers_fe)
+                       stop_proxy(prs->peers_fe);
                prs = prs->next;
        }
        /* signal zero is used to broadcast the "stopping" event */
@@ -1071,8 +1072,8 @@ void pause_proxies(void)
 
        prs = peers;
        while (prs) {
-               p = prs->peers_fe;
-               err |= !pause_proxy(p);
+               if (prs->peers_fe)
+                       err |= !pause_proxy(prs->peers_fe);
                prs = prs->next;
         }
 
@@ -1105,8 +1106,8 @@ void resume_proxies(void)
 
        prs = peers;
        while (prs) {
-               p = prs->peers_fe;
-               err |= !resume_proxy(p);
+               if (prs->peers_fe)
+                       err |= !resume_proxy(prs->peers_fe);
                prs = prs->next;
         }