From 84b57dae4a222e9aece07cb6449c06529ffa469f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 14 Jun 2009 11:10:45 +0200 Subject: [PATCH] [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. --- include/types/proxy.h | 4 ++++ src/cfgparse.c | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/types/proxy.h b/include/types/proxy.h index 9e49bd8305..b1b90e887d 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -290,6 +290,10 @@ struct proxy { unsigned int backlog; /* force the frontend's listen backlog */ unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */ 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 { diff --git a/src/cfgparse.c b/src/cfgparse.c index b268d598ae..2e079c71da 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -773,6 +773,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv) curproxy->state = defproxy.state; curproxy->options = defproxy.options; curproxy->options2 = defproxy.options2; + curproxy->no_options = defproxy.no_options; + curproxy->no_options2 = defproxy.no_options2; curproxy->bind_proc = defproxy.bind_proc; curproxy->lbprm.algo = defproxy.lbprm.algo; 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)) return 0; - if (!inv) - curproxy->options |= cfg_opts[optnum].val; - else - curproxy->options &= ~cfg_opts[optnum].val; + if (!inv) { + curproxy->no_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; } @@ -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)) return 0; - if (!inv) - curproxy->options2 |= cfg_opts2[optnum].val; - else - curproxy->options2 &= ~cfg_opts2[optnum].val; - + if (!inv) { + curproxy->no_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; } }