]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: config: compute the exact bind-process before listener's maxaccept
authorWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2014 11:41:21 +0000 (13:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2014 13:43:24 +0000 (15:43 +0200)
This is a continuation of previous patch, the listener's maxaccept is divided
by the number of processes, so it's best if we can swap the two blocks so that
the number of processes is already known when computing the maxaccept value.

src/cfgparse.c

index 32b91a334f521eb0f8f7d27e4720a3e18de97d57..05b8f8a11cb436f1ff988d40bd1da11d118aea74 100644 (file)
@@ -6094,13 +6094,12 @@ int check_config_validity()
                proxy = next;
        }
 
-       while (curproxy != NULL) {
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
                struct switching_rule *rule;
                struct server_rule *srule;
                struct sticking_rule *mrule;
                struct tcp_rule *trule;
                struct http_req_rule *hrqrule;
-               struct listener *listener;
                unsigned int next_id;
                int nbproc;
 
@@ -6168,14 +6167,6 @@ int check_config_validity()
                        }
                }
 
-               /* 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.
-                */
-
-               nbproc = global.nbproc;
-               if (curproxy->bind_proc)
-                       nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
-
                if (global.nbproc > 1 && curproxy->table.peers.name) {
                        Alert("Proxy '%s': peers can't be used in multi-process mode (nbproc > 1).\n",
                              curproxy->id);
@@ -7139,6 +7130,86 @@ out_uri_auth_compat:
                        if (curproxy->options2 & PR_O2_RDPC_PRST)
                                curproxy->be_req_ana |= AN_REQ_PRST_RDP_COOKIE;
                }
+       }
+
+       /***********************************************************/
+       /* At this point, target names have already been resolved. */
+       /***********************************************************/
+
+       /* Check multi-process mode compatibility */
+
+       if (global.nbproc > 1 && global.stats_fe) {
+               list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+                       unsigned long mask;
+
+                       mask = nbits(global.nbproc);
+                       if (global.stats_fe->bind_proc)
+                               mask &= global.stats_fe->bind_proc;
+
+                       if (bind_conf->bind_proc)
+                               mask &= bind_conf->bind_proc;
+
+                       /* stop here if more than one process is used */
+                       if (popcount(mask) > 1)
+                               break;
+               }
+               if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
+                       Warning("stats socket will not work as expected in multi-process mode (nbproc > 1), you should force process binding globally using 'stats bind-process' or per socket using the 'process' attribute.\n");
+               }
+       }
+
+       /* Make each frontend inherit bind-process from its listeners when not specified. */
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               if (curproxy->bind_proc)
+                       continue;
+
+               list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
+                       unsigned long mask;
+
+                       mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
+                       curproxy->bind_proc |= mask;
+               }
+
+               if (!curproxy->bind_proc)
+                       curproxy->bind_proc = ~0UL;
+       }
+
+       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;
+                       global.stats_fe->bind_proc |= mask;
+               }
+               if (!global.stats_fe->bind_proc)
+                       global.stats_fe->bind_proc = ~0UL;
+       }
+
+       /* propagate bindings from frontends to backends */
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               if (curproxy->cap & PR_CAP_FE)
+                       propagate_processes(curproxy, NULL);
+       }
+
+       /* Bind each unbound backend to all processes when not specified. */
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               if (curproxy->bind_proc)
+                       continue;
+               curproxy->bind_proc = ~0UL;
+       }
+
+       /*******************************************************/
+       /* At this step, all proxies have a non-null bind_proc */
+       /*******************************************************/
+
+       /* perform the final checks before creating tasks */
+
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               struct listener *listener;
+               unsigned int next_id;
+               int nbproc;
+
+               nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
 
 #ifdef USE_OPENSSL
                /* Configure SSL for each bind line.
@@ -7283,71 +7354,6 @@ out_uri_auth_compat:
                              curproxy->id);
                        cfgerr++;
                }
-
-               curproxy = curproxy->next;
-       }
-
-       /* Check multi-process mode compatibility */
-       if (global.nbproc > 1 && global.stats_fe) {
-               list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
-                       unsigned long mask;
-
-                       mask = nbits(global.nbproc);
-                       if (global.stats_fe->bind_proc)
-                               mask &= global.stats_fe->bind_proc;
-
-                       if (bind_conf->bind_proc)
-                               mask &= bind_conf->bind_proc;
-
-                       /* stop here if more than one process is used */
-                       if (popcount(mask) > 1)
-                               break;
-               }
-               if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
-                       Warning("stats socket will not work as expected in multi-process mode (nbproc > 1), you should force process binding globally using 'stats bind-process' or per socket using the 'process' attribute.\n");
-               }
-       }
-
-       /* At this point, target names have already been resolved */
-
-       /* Make each frontend inherit bind-process from its listeners when not specified. */
-       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
-               if (curproxy->bind_proc)
-                       continue;
-
-               list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
-                       unsigned long mask;
-
-                       mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
-                       curproxy->bind_proc |= mask;
-               }
-
-               if (!curproxy->bind_proc)
-                       curproxy->bind_proc = ~0UL;
-       }
-
-       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;
-                       global.stats_fe->bind_proc |= mask;
-               }
-               if (!global.stats_fe->bind_proc)
-                       global.stats_fe->bind_proc = ~0UL;
-       }
-
-       /* propagate bindings from frontends to backends */
-       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
-               if (curproxy->cap & PR_CAP_FE)
-                       propagate_processes(curproxy, NULL);
-       }
-
-       /* Bind each unbound backend to all processes when not specified. */
-       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
-               if (curproxy->bind_proc)
-                       continue;
-               curproxy->bind_proc = ~0UL;
        }
 
        /* automatically compute fullconn if not set. We must not do it in the