From: Valentine Krasnobaeva Date: Tue, 1 Oct 2024 14:09:29 +0000 (+0200) Subject: MEDIUM: cfgparse: call some parsers only in MODE_DISCOVERY X-Git-Tag: v3.1-dev10~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48371e6a3093c406933857e74bbfb0c9903052f2;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 825bc4c934..87adf1b892 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 90caed279a..c47625c761 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;