]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] config: track "no option"/"option" changes
authorWilly Tarreau <w@1wt.eu>
Sun, 14 Jun 2009 09:10:45 +0000 (11:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 14 Jun 2009 09:10:45 +0000 (11:10 +0200)
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
src/cfgparse.c

index 9e49bd83052d269ed809f33ad33d810b150394c8..b1b90e887d3d52f2faf1792764ea430c02957c9d 100644 (file)
@@ -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 {
index b268d598ae1af2a522460e74b9881ec21535782c..2e079c71da901ed99e681a3be7a119304a8b41ab 100644 (file)
@@ -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;
                        }
                }