]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: listener: inherit the process mask from the proxy
authorWilly Tarreau <w@1wt.eu>
Fri, 9 May 2014 15:06:11 +0000 (17:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 May 2014 17:16:26 +0000 (19:16 +0200)
When a process list is specified on either the proxy or the bind lines,
the latter is refined to the intersection of the two. A warning is emitted
if no intersection is found, and the situation is fixed by either falling
back to the first process of the proxy or to all processes.

src/cfgparse.c

index 0920eac5f2b40a58a9fa965d8215d89bf8dd6c6f..23e2bdd18826f401ede422d99342c7e265ee4744 100644 (file)
@@ -5870,6 +5870,33 @@ int check_config_validity()
                        }
                }
 
+               /* check and reduce the bind-proc of each listener */
+               list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
+                       unsigned long mask;
+
+                       if (!bind_conf->bind_proc)
+                               continue;
+
+                       mask = nbits(global.nbproc);
+                       if (curproxy->bind_proc)
+                               mask &= curproxy->bind_proc;
+                       /* mask cannot be null here thanks to the previous checks */
+
+                       nbproc = popcount(bind_conf->bind_proc);
+                       bind_conf->bind_proc &= mask;
+
+                       if (!bind_conf->bind_proc && nbproc == 1) {
+                               Warning("Proxy '%s': the process number specified on the 'process' directive of 'bind %s' at [%s:%d] refers to a process not covered by the proxy. This has been fixed by forcing it to run on the proxy's first process only.\n",
+                                       curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line);
+                               bind_conf->bind_proc = mask & ~(mask - 1);
+                       }
+                       else if (!bind_conf->bind_proc && nbproc > 1) {
+                               Warning("Proxy '%s': the process range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to processes not covered by the proxy. The directive was ignored so that all of the proxy's processes are used.\n",
+                                       curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line);
+                               bind_conf->bind_proc = 0;
+                       }
+               }
+
                /* here, if bind_proc is null, it means no limit, otherwise it's explicit.
                 * We now check how many processes the proxy will effectively run on.
                 */