]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: Useless frontend initialization in "peers" sections.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 25 Apr 2018 13:32:18 +0000 (15:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2019 13:26:21 +0000 (14:26 +0100)
Use ->local "peers" struct member to flag a "peers" section frontend
has being initialized. This is to be able to initialize the frontend
of "peers" sections on lines different from "peer" lines.

May be backported to 1.5 and newer.

src/cfgparse.c

index 92073a214d460c2d9687ecb12a65a10cf1a36b91..b7c85fa4030034fa2ccb472ede5a210ab9a59a54 100644 (file)
@@ -647,9 +647,16 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                        /* We are done. */
                        goto out;
 
+               if (cfg_peers->local) {
+                       ha_alert("parsing [%s:%d] : '%s %s' : local peer name already referenced at %s:%d.\n",
+                                file, linenum, args[0], args[1],
+                                curpeers->peers_fe->conf.file, curpeers->peers_fe->conf.line);
+                       err_code |= ERR_FATAL;
+                       goto out;
+               }
+
                /* Current is local peer, it define a frontend */
                newpeer->local = 1;
-               cfg_peers->local = newpeer;
 
                if (!curpeers->peers_fe) {
                        if (init_peers_frontend(file, linenum, args[1], curpeers) != 0) {
@@ -682,13 +689,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                                l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                                global.maxsock += l->maxconn;
                        }
-               }
-               else {
-                       ha_alert("parsing [%s:%d] : '%s %s' : local peer name already referenced at %s:%d.\n",
-                                file, linenum, args[0], args[1],
-                                curpeers->peers_fe->conf.file, curpeers->peers_fe->conf.line);
-                       err_code |= ERR_FATAL;
-                       goto out;
+                       cfg_peers->local = newpeer;
                }
        } /* neither "peer" nor "peers" */
        else if (!strcmp(args[0], "disabled")) {  /* disables this peers section */