From f9123e21836a0c1646d2d47ae20a5b391344ad14 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Fri, 9 Aug 2024 18:46:20 +0200 Subject: [PATCH] MEDIUM: cfgparse: add KWF_DISCOVERY keyword flag This commit is a part of the series to add a support of discovery mode in the configuration parser and in initialization sequence. So, let's add here KWF_DISCOVERY flag to distinguish the keywords, which should be parsed in "discovery" mode and which are needed for master process, from all others. Keywords, that should be parsed in "discovery" mode have its dedicated parser funtions. Let's tag these functions with KWF_DISCOVERY flag in keywords list. Like this, only these keyword parsers might be called during the first configuration read in discovery mode. --- include/haproxy/cfgparse.h | 1 + src/cfgparse-global.c | 18 +++++++++--------- src/mworker.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/haproxy/cfgparse.h b/include/haproxy/cfgparse.h index 8b760cdae..03e891ccf 100644 --- a/include/haproxy/cfgparse.h +++ b/include/haproxy/cfgparse.h @@ -49,6 +49,7 @@ enum kw_mod { enum cfg_keyword_flags { KWF_EXPERIMENTAL = 0x1, KWF_MATCH_PREFIX = 0x2, + KWF_DISCOVERY = 0x4, }; struct cfg_keyword { diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 5be150f5f..825bc4c93 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1521,15 +1521,15 @@ static struct cfg_kw_list cfg_kws = {ILH, { { CFG_GLOBAL, "force-cfg-parser-pause", cfg_parse_global_parser_pause, KWF_EXPERIMENTAL }, { CFG_GLOBAL, "harden.reject-privileged-ports.tcp", cfg_parse_reject_privileged_ports }, { CFG_GLOBAL, "harden.reject-privileged-ports.quic", cfg_parse_reject_privileged_ports }, - { CFG_GLOBAL, "master-worker", cfg_parse_global_master_worker }, - { CFG_GLOBAL, "daemon", cfg_parse_global_mode } , - { CFG_GLOBAL, "quiet", cfg_parse_global_mode }, - { CFG_GLOBAL, "zero-warning", cfg_parse_global_mode }, - { CFG_GLOBAL, "noepoll", cfg_parse_global_disable_poller }, - { CFG_GLOBAL, "nokqueue", cfg_parse_global_disable_poller }, - { CFG_GLOBAL, "noevports", cfg_parse_global_disable_poller }, - { CFG_GLOBAL, "nopoll", cfg_parse_global_disable_poller }, - { CFG_GLOBAL, "pidfile", cfg_parse_global_pidfile }, + { CFG_GLOBAL, "master-worker", cfg_parse_global_master_worker, KWF_DISCOVERY }, + { CFG_GLOBAL, "daemon", cfg_parse_global_mode, KWF_DISCOVERY } , + { CFG_GLOBAL, "quiet", cfg_parse_global_mode, KWF_DISCOVERY }, + { CFG_GLOBAL, "zero-warning", cfg_parse_global_mode, KWF_DISCOVERY }, + { CFG_GLOBAL, "noepoll", cfg_parse_global_disable_poller, KWF_DISCOVERY }, + { CFG_GLOBAL, "nokqueue", cfg_parse_global_disable_poller, KWF_DISCOVERY }, + { CFG_GLOBAL, "noevports", cfg_parse_global_disable_poller, KWF_DISCOVERY }, + { CFG_GLOBAL, "nopoll", cfg_parse_global_disable_poller, KWF_DISCOVERY }, + { CFG_GLOBAL, "pidfile", cfg_parse_global_pidfile, KWF_DISCOVERY }, { CFG_GLOBAL, "expose-deprecated-directives", cfg_parse_global_non_std_directives }, { CFG_GLOBAL, "expose-experimental-directives", cfg_parse_global_non_std_directives }, { CFG_GLOBAL, "tune.runqueue-depth", cfg_parse_global_tune_opts }, diff --git a/src/mworker.c b/src/mworker.c index a5b55d24d..90caed279 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -843,7 +843,7 @@ void mworker_create_master_cli(void) } static struct cfg_kw_list mworker_kws = {{ }, { - { CFG_GLOBAL, "mworker-max-reloads", mworker_parse_global_max_reloads }, + { CFG_GLOBAL, "mworker-max-reloads", mworker_parse_global_max_reloads, KWF_DISCOVERY }, { 0, NULL, NULL }, }};