]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: init: check MODE_MWORKER before creating master CLI
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 9 Aug 2024 16:05:23 +0000 (18:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
mworker_create_master_cli() creates MASTER proxy and allocates listeners,
which are attached to this proxy. It also creates a reload sockpair.

So, it's more appropriate to do the check, that we are in a MODE_MWORKER, if
master CLI settings were provided via command line, just after the config
parsing. And only then, if runtime mode and command line settings are
coherent, try to perform master-worker fork and try to create master CLI.

src/haproxy.c

index 3a89a281fa095c1680e610f088d603c733704388..56a42727289006729eb27f3ef837f518d683a59a 100644 (file)
@@ -2062,6 +2062,11 @@ static void init(int argc, char **argv)
                        exit(1);
        }
 
+       if (!LIST_ISEMPTY(&mworker_cli_conf) && !(arg_mode & MODE_MWORKER)) {
+               ha_alert("a master CLI socket was defined, but master-worker mode (-W) is not enabled.\n");
+               exit(EXIT_FAILURE);
+       }
+
        if (global.mode & MODE_MWORKER) {
                struct mworker_proc *tmproc;
 
@@ -2207,11 +2212,6 @@ static void init(int argc, char **argv)
        if (master)
                mworker_create_master_cli();
 
-       if (!LIST_ISEMPTY(&mworker_cli_conf) && !(arg_mode & MODE_MWORKER)) {
-               ha_alert("a master CLI socket was defined, but master-worker mode (-W) is not enabled.\n");
-               exit(EXIT_FAILURE);
-       }
-
        /* destroy unreferenced defaults proxies  */
        proxy_destroy_all_unref_defaults();