]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: init: stop any peers section not bound to the correct process
authorWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 17:13:41 +0000 (19:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 18:16:31 +0000 (20:16 +0200)
This will prevent the peers section from remaining in listen state on
the incorrect process. The peers_fe pointer is set to NULL, which will
tell the peers task to commit suicide if it was already scheduled.

src/haproxy.c

index b5144a7fd66838d2f75d9fa86944fc73bbc0c759..233c434b46cb7c2c2997501f47e1cd65bb45a040 100644 (file)
@@ -1740,6 +1740,7 @@ int main(int argc, char **argv)
 
        if (global.mode & (MODE_DAEMON | MODE_SYSTEMD)) {
                struct proxy *px;
+               struct peers *curpeers;
                int ret = 0;
                int *children = calloc(global.nbproc, sizeof(int));
                int proc;
@@ -1799,6 +1800,19 @@ int main(int argc, char **argv)
                        px = px->next;
                }
 
+               /* we might have to unbind some peers sections from some processes */
+               for (curpeers = peers; curpeers; curpeers = curpeers->next) {
+                       if (!curpeers->peers_fe)
+                               continue;
+
+                       if (curpeers->peers_fe->bind_proc & (1UL << proc))
+                               continue;
+
+                       stop_proxy(curpeers->peers_fe);
+                       /* disable this peer section so that it kills itself */
+                       curpeers->peers_fe = NULL;
+               }
+
                free(children);
                children = NULL;
                /* if we're NOT in QUIET mode, we should now close the 3 first FDs to ensure