mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-20 12:46:56 +00:00
MINOR: cfgparse-global: move mode's keywords in cfg_kw_list
This commit cleans up cfg_parse_global() and prepares the config parser for master-worker mode refactoring, where daemon and master-worker fork() calls will happen very early in init(). So, the config in such case should be read twice: - at first: only some keywords in the global section for the mode discovery and everything, which is related to master process by opportunity; - at second: except the master process, all other keywords would be parsed;
This commit is contained in:
parent
d3d35f0fc6
commit
118ac11cea
@ -81,25 +81,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
else if (strcmp(args[0], "expose-experimental-directives") == 0) {
|
||||
experimental_directives_allowed = 1;
|
||||
}
|
||||
else if (strcmp(args[0], "daemon") == 0) {
|
||||
if (alertif_too_many_args(0, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
global.mode |= MODE_DAEMON;
|
||||
}
|
||||
else if (strcmp(args[0], "master-worker") == 0) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*args[1]) {
|
||||
if (strcmp(args[1], "no-exit-on-failure") == 0) {
|
||||
global.tune.options |= GTUNE_NOEXIT_ONFAILURE;
|
||||
} else {
|
||||
ha_alert("parsing [%s:%d] : '%s' only supports 'no-exit-on-failure' option.\n", file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
global.mode |= MODE_MWORKER;
|
||||
}
|
||||
else if (strcmp(args[0], "noepoll") == 0) {
|
||||
if (alertif_too_many_args(0, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
@ -187,16 +168,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
protocol_clrf_all(PROTO_F_REUSEPORT_SUPPORTED);
|
||||
}
|
||||
else if (strcmp(args[0], "quiet") == 0) {
|
||||
if (alertif_too_many_args(0, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
global.mode |= MODE_QUIET;
|
||||
}
|
||||
else if (strcmp(args[0], "zero-warning") == 0) {
|
||||
if (alertif_too_many_args(0, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
global.mode |= MODE_ZERO_WARNING;
|
||||
}
|
||||
else if (strcmp(args[0], "tune.runqueue-depth") == 0) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
@ -1425,10 +1396,61 @@ static int cfg_parse_reject_privileged_ports(char **args, int section_type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parser for master-worker mode */
|
||||
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 (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
if (*args[1]) {
|
||||
if (strcmp(args[1], "no-exit-on-failure") == 0)
|
||||
global.tune.options |= GTUNE_NOEXIT_ONFAILURE;
|
||||
else {
|
||||
memprintf(err, "parsing [%s:%d] : '%s' only supports 'no-exit-on-failure' option",
|
||||
file, line, args[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
global.mode |= MODE_MWORKER;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parser for other modes */
|
||||
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 (too_many_args(0, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
if (strcmp(args[0], "daemon") == 0) {
|
||||
global.mode |= MODE_DAEMON;
|
||||
|
||||
} else if (strcmp(args[0], "quiet") == 0) {
|
||||
global.mode |= MODE_QUIET;
|
||||
|
||||
} else if (strcmp(args[0], "zero-warning") == 0) {
|
||||
global.mode |= MODE_ZERO_WARNING;
|
||||
|
||||
} else {
|
||||
BUG_ON(1, "Triggered in cfg_parse_global_mode() by unsupported keyword.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "prealloc-fd", cfg_parse_prealloc_fd },
|
||||
{ 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 },
|
||||
{ 0, NULL, NULL },
|
||||
}};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user