From e4c10a704d3374e1e51efe820b865f62fe5b3844 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Fri, 9 Aug 2024 18:05:23 +0200 Subject: [PATCH] MINOR: init: check MODE_MWORKER before creating master CLI 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 3a89a281f..56a427272 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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();