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.
This commit is contained in:
Valentine Krasnobaeva 2024-10-01 16:09:29 +02:00 committed by Willy Tarreau
parent f9123e2183
commit 48371e6a30
2 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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;