]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] Keep in sync "defaults" support between documentation and code
authorCyril Bonté <cyril.bonte@free.fr>
Sun, 24 Jan 2010 22:29:44 +0000 (23:29 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Jan 2010 22:16:58 +0000 (23:16 +0100)
Hi Willy,

I've made a quick pass on the "defaults" column in the Proxy keywords matrix (chapter 4.1. in the documentation).
This patch resyncs the code and the documentation. I let you decide if some keywords that still work in the "defaults" section should be forbidden.

- default_backend : in the matrix, "defaults" was not supported but the keyword details say it is.
Tests also shows it works, then I've updated the matrix.

- capture cookie : in the keyword details, we can read `It is not possible to specify a capture in a "defaults" section.'.
Ok, even if the tests worked, I've added an alert in the configuration parser (as it is for capture request/response header).

- description : not supported in "defaults", I added an alert in the parser.
I've also noticed that this keyword doesn't appear in the documentation.
There's one "description" entry, but for the "global" section, which is for a different use (the patch doesn't update the documentation).

- grace : even if this is maybe useless, it works in "defaults". Documentation is updated.
- redirect : alert is added in the parser.
- rsprep : alert added in the parser.

--
Cyril Bonté

(cherry picked from commit 99ed327d6269eeddfd15b5fdb7ad22ffde41a83c)

doc/configuration.txt
src/cfgparse.c

index a66de24691f237f160c2329d5cec67b65b7abe59..c96051ba290f8ff39079b5c381742eccc309a052 100644 (file)
@@ -686,7 +686,7 @@ capture response header     -          X         X         -
 clitimeout                  X          X         X         -  (deprecated)
 contimeout                  X          -         X         X  (deprecated)
 cookie                      X          -         X         X
-default_backend             -          X         X         -
+default_backend             X          X         X         -
 description                 -          X         X         X
 disabled                    X          X         X         X
 dispatch                    -          -         X         X
@@ -696,7 +696,7 @@ errorloc                    X          X         X         X
 errorloc302                 X          X         X         X
 errorloc303                 X          X         X         X
 fullconn                    X          -         X         X
-grace                       -          X         X         X
+grace                       X          X         X         X
 http-check disable-on-404   X          -         X         X
 log                         X          X         X         X
 maxconn                     X          X         X         -
@@ -1676,7 +1676,7 @@ fullconn <conns>
 grace <time>
   Maintain a proxy operational for some time after a soft stop
   May be used in sections :   defaults | frontend | listen | backend
-                                  no   |    yes   |   yes  |   yes
+                                 yes   |    yes   |   yes  |   yes
   Arguments :
     <time>    is the time (by default in milliseconds) for which the instance
               will remain operational with the frontend sockets still listening
index d11bb22810a8df49c5a3950090c963596c0a93b9..8903a820521ea045d35cf20711a065e4665f8281 100644 (file)
@@ -1172,6 +1172,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                int i, len=0;
                char *d;
 
+               if (curproxy == &defproxy) {
+                       Alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n",
+                                file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+
                if (!*args[1]) {
                        Alert("parsing [%s:%d]: '%s' expects a string argument.\n",
                                file, linenum, args[0]);
@@ -1402,6 +1409,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                        err_code |= ERR_WARN;
 
                if (!strcmp(args[1], "cookie")) {  /* name of a cookie to capture */
+                       if (curproxy == &defproxy) {
+                               Alert("parsing [%s:%d] : '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]);
+                               err_code |= ERR_ALERT | ERR_FATAL;
+                               goto out;
+                       }
+
                        if (*(args[4]) == 0) {
                                Alert("parsing [%s:%d] : '%s' expects 'cookie' <cookie_name> 'len' <len>.\n",
                                      file, linenum, args[0]);
@@ -1534,6 +1547,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                int cookie_set = 0;
                unsigned int flags = REDIRECT_FLAG_NONE;
 
+               if (curproxy == &defproxy) {
+                       Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+
                cur_arg = 1;
                while (*(args[cur_arg])) {
                        if (!strcmp(args[cur_arg], "location")) {
@@ -3328,6 +3347,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
        }
        else if (!strcmp(args[0], "srvexp") || !strcmp(args[0], "rsprep")) {  /* replace response header from a regex */
                regex_t *preg;
+               if (curproxy == &defproxy) {
+                       Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
        
                if (*(args[1]) == 0 || *(args[2]) == 0) {
                        Alert("parsing [%s:%d] : '%s' expects <search> and <replace> as arguments.\n",