MEDIUM: config: validate that peers sections are bound to exactly one process
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.
(cherry picked from commit 1e273018663ac1e4b8f0a0b23fd238c5a7e2dc28)
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 9812ec2..3cc3678 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -7409,9 +7409,9 @@
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) {
@@ -7427,6 +7427,18 @@
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;