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.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index cf6637b..aa03995 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -7907,9 +7907,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) {
@@ -7925,6 +7925,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;