[MINOR] config: track "no option"/"option" changes

Sometimes we would want to implement implicit default options,
but for this we need to be able to disable them, which requires
to keep track of "no option" settings. With this change, an option
explicitly disabled in a defaults section will still be seen as
explicitly disabled. There should be no regression as nothing makes
use of this yet.
This commit is contained in:
Willy Tarreau 2009-06-14 11:10:45 +02:00
parent c6f4ce8fc4
commit 84b57dae4a
2 changed files with 20 additions and 9 deletions

View File

@ -290,6 +290,10 @@ struct proxy {
unsigned int backlog; /* force the frontend's listen backlog */ unsigned int backlog; /* force the frontend's listen backlog */
unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */ unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */
struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */ struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */
/* used only during configuration parsing */
int no_options; /* PR_O_REDISP, PR_O_TRANSP, ... */
int no_options2; /* PR_O2_* */
}; };
struct switching_rule { struct switching_rule {

View File

@ -773,6 +773,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
curproxy->state = defproxy.state; curproxy->state = defproxy.state;
curproxy->options = defproxy.options; curproxy->options = defproxy.options;
curproxy->options2 = defproxy.options2; curproxy->options2 = defproxy.options2;
curproxy->no_options = defproxy.no_options;
curproxy->no_options2 = defproxy.no_options2;
curproxy->bind_proc = defproxy.bind_proc; curproxy->bind_proc = defproxy.bind_proc;
curproxy->lbprm.algo = defproxy.lbprm.algo; curproxy->lbprm.algo = defproxy.lbprm.algo;
curproxy->except_net = defproxy.except_net; curproxy->except_net = defproxy.except_net;
@ -1594,10 +1596,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
if (warnifnotcap(curproxy, cfg_opts[optnum].cap, file, linenum, args[1], NULL)) if (warnifnotcap(curproxy, cfg_opts[optnum].cap, file, linenum, args[1], NULL))
return 0; return 0;
if (!inv) if (!inv) {
curproxy->options |= cfg_opts[optnum].val; curproxy->no_options &= ~cfg_opts[optnum].val;
else curproxy->options |= cfg_opts[optnum].val;
curproxy->options &= ~cfg_opts[optnum].val; } else {
curproxy->options &= ~cfg_opts[optnum].val;
curproxy->no_options |= cfg_opts[optnum].val;
}
return 0; return 0;
} }
@ -1608,11 +1613,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
if (warnifnotcap(curproxy, cfg_opts2[optnum].cap, file, linenum, args[1], NULL)) if (warnifnotcap(curproxy, cfg_opts2[optnum].cap, file, linenum, args[1], NULL))
return 0; return 0;
if (!inv) if (!inv) {
curproxy->options2 |= cfg_opts2[optnum].val; curproxy->no_options2 &= ~cfg_opts2[optnum].val;
else curproxy->options2 |= cfg_opts2[optnum].val;
curproxy->options2 &= ~cfg_opts2[optnum].val; } else {
curproxy->options2 &= ~cfg_opts2[optnum].val;
curproxy->no_options2 |= cfg_opts2[optnum].val;
}
return 0; return 0;
} }
} }