1 From 91b00c2194b728ccd61133cca83f03de3650b674 Mon Sep 17 00:00:00 2001
2 From: Willy Tarreau <w@1wt.eu>
3 Date: Tue, 16 Sep 2014 13:41:21 +0200
4 Subject: [PATCH 10/13] MEDIUM: config: compute the exact bind-process before
7 This is a continuation of previous patch, the listener's maxaccept is divided
8 by the number of processes, so it's best if we can swap the two blocks so that
9 the number of processes is already known when computing the maxaccept value.
10 (cherry picked from commit 419ead8eca9237f9cc2ec32630d96fde333282ee)
12 src/cfgparse.c | 156 ++++++++++++++++++++++++++++++---------------------------
13 1 file changed, 81 insertions(+), 75 deletions(-)
15 diff --git a/src/cfgparse.c b/src/cfgparse.c
16 index d53f69e..f3907bf 100644
19 @@ -6042,12 +6042,11 @@ int check_config_validity()
23 - while (curproxy != NULL) {
24 + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
25 struct switching_rule *rule;
26 struct server_rule *srule;
27 struct sticking_rule *mrule;
28 struct tcp_rule *trule;
29 - struct listener *listener;
33 @@ -6115,14 +6114,6 @@ int check_config_validity()
37 - /* here, if bind_proc is null, it means no limit, otherwise it's explicit.
38 - * We now check how many processes the proxy will effectively run on.
41 - nbproc = global.nbproc;
42 - if (curproxy->bind_proc)
43 - nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
45 if (global.nbproc > 1 && curproxy->table.peers.name) {
46 Alert("Proxy '%s': peers can't be used in multi-process mode (nbproc > 1).\n",
48 @@ -7005,6 +6996,86 @@ out_uri_auth_compat:
49 if (curproxy->options2 & PR_O2_RDPC_PRST)
50 curproxy->be_req_ana |= AN_REQ_PRST_RDP_COOKIE;
54 + /***********************************************************/
55 + /* At this point, target names have already been resolved. */
56 + /***********************************************************/
58 + /* Check multi-process mode compatibility */
60 + if (global.nbproc > 1 && global.stats_fe) {
61 + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
64 + mask = nbits(global.nbproc);
65 + if (global.stats_fe->bind_proc)
66 + mask &= global.stats_fe->bind_proc;
68 + if (bind_conf->bind_proc)
69 + mask &= bind_conf->bind_proc;
71 + /* stop here if more than one process is used */
72 + if (popcount(mask) > 1)
75 + if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
76 + 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");
80 + /* Make each frontend inherit bind-process from its listeners when not specified. */
81 + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
82 + if (curproxy->bind_proc)
85 + list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
88 + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
89 + curproxy->bind_proc |= mask;
92 + if (!curproxy->bind_proc)
93 + curproxy->bind_proc = ~0UL;
96 + if (global.stats_fe) {
97 + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
100 + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
101 + global.stats_fe->bind_proc |= mask;
103 + if (!global.stats_fe->bind_proc)
104 + global.stats_fe->bind_proc = ~0UL;
107 + /* propagate bindings from frontends to backends */
108 + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
109 + if (curproxy->cap & PR_CAP_FE)
110 + propagate_processes(curproxy, NULL);
113 + /* Bind each unbound backend to all processes when not specified. */
114 + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
115 + if (curproxy->bind_proc)
117 + curproxy->bind_proc = ~0UL;
120 + /*******************************************************/
121 + /* At this step, all proxies have a non-null bind_proc */
122 + /*******************************************************/
124 + /* perform the final checks before creating tasks */
126 + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
127 + struct listener *listener;
128 + unsigned int next_id;
131 + nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
134 /* Configure SSL for each bind line.
135 @@ -7149,71 +7220,6 @@ out_uri_auth_compat:
140 - curproxy = curproxy->next;
143 - /* Check multi-process mode compatibility */
144 - if (global.nbproc > 1 && global.stats_fe) {
145 - list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
146 - unsigned long mask;
148 - mask = nbits(global.nbproc);
149 - if (global.stats_fe->bind_proc)
150 - mask &= global.stats_fe->bind_proc;
152 - if (bind_conf->bind_proc)
153 - mask &= bind_conf->bind_proc;
155 - /* stop here if more than one process is used */
156 - if (popcount(mask) > 1)
159 - if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
160 - 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");
164 - /* At this point, target names have already been resolved */
166 - /* Make each frontend inherit bind-process from its listeners when not specified. */
167 - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
168 - if (curproxy->bind_proc)
171 - list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
172 - unsigned long mask;
174 - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
175 - curproxy->bind_proc |= mask;
178 - if (!curproxy->bind_proc)
179 - curproxy->bind_proc = ~0UL;
182 - if (global.stats_fe) {
183 - list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
184 - unsigned long mask;
186 - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
187 - global.stats_fe->bind_proc |= mask;
189 - if (!global.stats_fe->bind_proc)
190 - global.stats_fe->bind_proc = ~0UL;
193 - /* propagate bindings from frontends to backends */
194 - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
195 - if (curproxy->cap & PR_CAP_FE)
196 - propagate_processes(curproxy, NULL);
199 - /* Bind each unbound backend to all processes when not specified. */
200 - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
201 - if (curproxy->bind_proc)
203 - curproxy->bind_proc = ~0UL;
206 /* automatically compute fullconn if not set. We must not do it in the