BUG/MINOR: mworker: don't use oldpids[] anymore for reload
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 21 Apr 2021 14:55:34 +0000 (16:55 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 29 Apr 2021 09:11:12 +0000 (11:11 +0200)
Since commit 3f12887 ("MINOR: mworker: don't use children variable
anymore"), the oldpids array is not used anymore to generate the new -sf
parameters. So we don't need to set nb_oldpids to 0 during the first
start of the master process.

This patch fixes a bug when 2 masters process tries to synchronize their
peers, there is a small chances that it won't work because nb_oldpids
equals 0.

Should be backported as far as 2.0.

(cherry picked from commit aba7f8b3132de3b29efe634cad8fb574f259549b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 450592728877401e52274d2138f1379799e8f3f6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 357beb1de6dd16f210bdc9d487f7fc4fa9c3da96)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/haproxy.c

index fd05485..f793267 100644 (file)
@@ -815,7 +815,7 @@ void mworker_reload()
                old_argc++;
 
        /* 1 for haproxy -sf, 2 for -x /socket */
-       next_argv = calloc(old_argc + 1 + 2 + mworker_child_nb() + nb_oldpids + 1, sizeof(char *));
+       next_argv = calloc(old_argc + 1 + 2 + mworker_child_nb() + 1, sizeof(char *));
        if (next_argv == NULL)
                goto alloc_error;
 
@@ -3320,13 +3320,6 @@ int main(int argc, char **argv)
        if ((global.mode & MODE_MWORKER) && !(global.mode & MODE_MWORKER_WAIT))
                mworker_kill_max_reloads(SIGTERM);
 
-       if ((global.mode & MODE_MWORKER) && (getenv("HAPROXY_MWORKER_REEXEC") == NULL)) {
-               nb_oldpids = 0;
-               free(oldpids);
-               oldpids = NULL;
-       }
-
-
        /* Note that any error at this stage will be fatal because we will not
         * be able to restart the old pids.
         */