From 48371e6a3093c406933857e74bbfb0c9903052f2 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Tue, 1 Oct 2024 16:09:29 +0200 Subject: [PATCH] MEDIUM: cfgparse: call some parsers only in MODE_DISCOVERY This commit is a part of the series to add a support of discovery mode in the configuration parser and in initialization sequence. Some keyword parsers tagged with KWF_DISCOVERY (for example those, which parse runtime modes, poller types, pidfile), should not be called twice when the configuration will be read the second time after the discovery mode. It's redundant and could trigger parser's errors in standalone mode. In master-worker mode the worker process inherits parsed settings from the master. --- src/cfgparse-global.c | 12 ++++++++++++ src/mworker.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 825bc4c93..87adf1b89 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -977,6 +977,9 @@ static int cfg_parse_global_master_worker(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int line, char **err) { + if (!(global.mode & MODE_DISCOVERY)) + return 0; + if (too_many_args(1, args, err, NULL)) return -1; @@ -999,6 +1002,9 @@ static int cfg_parse_global_mode(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int line, char **err) { + if (!(global.mode & MODE_DISCOVERY)) + return 0; + if (too_many_args(0, args, err, NULL)) return -1; @@ -1024,6 +1030,9 @@ static int cfg_parse_global_disable_poller(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int line, char **err) { + if (!(global.mode & MODE_DISCOVERY)) + return 0; + if (too_many_args(0, args, err, NULL)) return -1; @@ -1051,6 +1060,9 @@ static int cfg_parse_global_pidfile(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int line, char **err) { + if (!(global.mode & MODE_DISCOVERY)) + return 0; + if (too_many_args(1, args, err, NULL)) return -1; diff --git a/src/mworker.c b/src/mworker.c index 90caed279..c47625c76 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -751,6 +751,8 @@ static int mworker_parse_global_max_reloads(char **args, int section_type, struc { int err_code = 0; + if (!(global.mode & MODE_DISCOVERY)) + return 0; if (alertif_too_many_args(1, file, linenum, args, &err_code)) goto out; -- 2.47.3