From 337a6665724769929a1eb2039f03ce8c31e9e7db Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 28 Sep 2015 16:27:44 +0200 Subject: [PATCH] BUG/MEDIUM: proxy: ignore stopped peers 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/proxy.c b/src/proxy.c index 52e4bbe52b..1f2fc56156 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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; } -- 2.47.3