]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: config: validate that peers sections are bound to exactly one process
authorWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 17:15:17 +0000 (19:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2015 18:16:31 +0000 (20:16 +0200)
If a peers section is bound to no process, it's silently discarded. If its
bound to multiple processes, an error is emitted and the process will not
start.

src/cfgparse.c

index cf6637be89e767bbbe149f1d2219b6b73bd82109..aa039950f7c50a4e2965e94be54437bb8c2944d0 100644 (file)
@@ -7907,9 +7907,9 @@ out_uri_auth_compat:
                struct peers *curpeers = peers, **last;
                struct peer *p, *pb;
 
-               /* Remove all peers sections which don't have a valid listener.
-                * This can happen when a peers section is never referenced and
-                * does not contain a local peer.
+               /* Remove all peers sections which don't have a valid listener,
+                * which are not used by any table, or which are bound to more
+                * than one process.
                 */
                last = &peers;
                while (*last) {
@@ -7925,6 +7925,18 @@ out_uri_auth_compat:
                                Warning("Removing incomplete section 'peers %s' (no peer named '%s').\n",
                                        curpeers->id, localpeer);
                        }
+                       else if (popcount(curpeers->peers_fe->bind_proc) != 1) {
+                               /* either it's totally stopped or too much used */
+                               if (curpeers->peers_fe->bind_proc) {
+                                       Alert("Peers section '%s': peers referenced by sections "
+                                             "running in different processes. Check global.nbproc"
+                                             " and all tables' bind_proc settings.\n",
+                                             curpeers->id);
+                                       cfgerr++;
+                               }
+                               stop_proxy(curpeers->peers_fe);
+                               curpeers->peers_fe = NULL;
+                       }
                        else {
                                last = &curpeers->next;
                                continue;