From e428b08ee72879072897d1bcfa38589b7d1a89a5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 4 May 2015 21:57:58 +0200 Subject: [PATCH] BUG/MEDIUM: config: properly compute the default number of processes for a proxy Chad Lavoie reported an interesting regression caused by the latest updates to automatically detect the processes a peers section runs on. It turns out that if a config has neither nbproc nor a bind-process statement and depending on the frontend->backend chaining, it is possible to evade all bind_proc propagations, resulting in assigning only ~0UL (all processes, which is 32 or 64) without ever restricting it to nbproc. It was not visible in backends until they started to reference peers sections which saw themselves with 64 processes at once. This patch addresses this by replacing all those ~0UL with nbits(nbproc). That way all "bind-process" settings *default* to the number of processes defined in nbproc instead of 32 or 64. This fix could possibly be backported into 1.5, though there is no indication that this bug could have any effect there. --- src/cfgparse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index 13107e837..4d0a91a1e 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -7606,23 +7606,23 @@ out_uri_auth_compat: list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { unsigned long mask; - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL; + mask = bind_conf->bind_proc ? bind_conf->bind_proc : nbits(global.nbproc); curproxy->bind_proc |= mask; } if (!curproxy->bind_proc) - curproxy->bind_proc = ~0UL; + curproxy->bind_proc = nbits(global.nbproc); } if (global.stats_fe) { list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { unsigned long mask; - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL; + mask = bind_conf->bind_proc ? bind_conf->bind_proc : nbits(global.nbproc); global.stats_fe->bind_proc |= mask; } if (!global.stats_fe->bind_proc) - global.stats_fe->bind_proc = ~0UL; + global.stats_fe->bind_proc = nbits(global.nbproc); } /* propagate bindings from frontends to backends. Don't do it if there @@ -7639,7 +7639,7 @@ out_uri_auth_compat: for (curproxy = proxy; curproxy; curproxy = curproxy->next) { if (curproxy->bind_proc) continue; - curproxy->bind_proc = ~0UL; + curproxy->bind_proc = nbits(global.nbproc); } /*******************************************************/