mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
MEDIUM: global: remove dead code from nbproc/bind_proc removal
Lots of places iterating over nbproc or comparing with nbproc could be simplified. Further, "bind-process" and "process" parsing that was already limited to process 1 or "all" or "odd" resulted in a bind_proc field that was either 0 or 1 during the init phase and later always 1. All the checks for compatibilities were removed since it's not possible anymore to run a frontend and a backend on different processes or to have peers and stick-tables bound on different ones. This is the largest part of this patch. The bind_proc field was removed from both the proxy and the receiver structs. Since the "process" and "bind-process" directives are still parsed, configs making use of correct values allowing process 1 will continue to work.
This commit is contained in:
parent
5301f5d72a
commit
72faef3866
@ -391,7 +391,6 @@ struct proxy {
|
|||||||
unsigned int log_count; /* number of logs produced by the frontend */
|
unsigned int log_count; /* number of logs produced by the frontend */
|
||||||
int uuid; /* universally unique proxy ID, used for SNMP */
|
int uuid; /* universally unique proxy ID, used for SNMP */
|
||||||
unsigned int backlog; /* force the frontend's listen backlog */
|
unsigned int backlog; /* force the frontend's listen backlog */
|
||||||
unsigned long bind_proc; /* bitmask of processes using this proxy */
|
|
||||||
unsigned int li_all; /* total number of listeners attached to this proxy */
|
unsigned int li_all; /* total number of listeners attached to this proxy */
|
||||||
unsigned int li_paused; /* total number of listeners paused (LI_PAUSED) */
|
unsigned int li_paused; /* total number of listeners paused (LI_PAUSED) */
|
||||||
unsigned int li_bound; /* total number of listeners ready (LI_LISTEN) */
|
unsigned int li_bound; /* total number of listeners ready (LI_LISTEN) */
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
/* All the settings that are used to configure a receiver */
|
/* All the settings that are used to configure a receiver */
|
||||||
struct rx_settings {
|
struct rx_settings {
|
||||||
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
|
|
||||||
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
|
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
|
||||||
struct { /* UNIX socket permissions */
|
struct { /* UNIX socket permissions */
|
||||||
uid_t uid; /* -1 to leave unchanged */
|
uid_t uid; /* -1 to leave unchanged */
|
||||||
|
@ -74,11 +74,6 @@ int check_trk_action(struct act_rule *rule, struct proxy *px, char **err)
|
|||||||
rule->action);
|
rule->action);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (target->proxy && (px->bind_proc & ~target->proxy->bind_proc)) {
|
|
||||||
memprintf(err, "stick-table '%s' referenced by 'track-sc%d' rule not present on all processes covered by proxy '%s'",
|
|
||||||
target->id, rule->action, px->id);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (!in_proxies_list(target->proxies_list, px)) {
|
if (!in_proxies_list(target->proxies_list, px)) {
|
||||||
px->next_stkt_ref = target->proxies_list;
|
px->next_stkt_ref = target->proxies_list;
|
||||||
|
@ -609,14 +609,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
set = 0;
|
set = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (parse_process_number(args[cur_arg], &set, MAX_PROCS, NULL, &errmsg)) {
|
if (parse_process_number(args[cur_arg], &set, 1, NULL, &errmsg)) {
|
||||||
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
|
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
cur_arg++;
|
cur_arg++;
|
||||||
}
|
}
|
||||||
curproxy->bind_proc = set;
|
|
||||||
}
|
}
|
||||||
else if (strcmp(args[0], "acl") == 0) { /* add an ACL */
|
else if (strcmp(args[0], "acl") == 0) { /* add an ACL */
|
||||||
if (curproxy->cap & PR_CAP_DEF) {
|
if (curproxy->cap & PR_CAP_DEF) {
|
||||||
|
231
src/cfgparse.c
231
src/cfgparse.c
@ -2381,60 +2381,6 @@ int readcfgfile(const char *file)
|
|||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function propagates processes from frontend <from> to backend <to> so
|
|
||||||
* that it is always guaranteed that a backend pointed to by a frontend is
|
|
||||||
* bound to all of its processes. After that, if the target is a "listen"
|
|
||||||
* instance, the function recursively descends the target's own targets along
|
|
||||||
* default_backend and use_backend rules. Since the bits are
|
|
||||||
* checked first to ensure that <to> is already bound to all processes of
|
|
||||||
* <from>, there is no risk of looping and we ensure to follow the shortest
|
|
||||||
* path to the destination.
|
|
||||||
*
|
|
||||||
* It is possible to set <to> to NULL for the first call so that the function
|
|
||||||
* takes care of visiting the initial frontend in <from>.
|
|
||||||
*
|
|
||||||
* It is important to note that the function relies on the fact that all names
|
|
||||||
* have already been resolved.
|
|
||||||
*/
|
|
||||||
void propagate_processes(struct proxy *from, struct proxy *to)
|
|
||||||
{
|
|
||||||
struct switching_rule *rule;
|
|
||||||
|
|
||||||
if (to) {
|
|
||||||
/* check whether we need to go down */
|
|
||||||
if (from->bind_proc &&
|
|
||||||
(from->bind_proc & to->bind_proc) == from->bind_proc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!from->bind_proc && !to->bind_proc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
to->bind_proc = from->bind_proc ?
|
|
||||||
(to->bind_proc | from->bind_proc) : 0;
|
|
||||||
|
|
||||||
/* now propagate down */
|
|
||||||
from = to;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(from->cap & PR_CAP_FE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (from->disabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* default_backend */
|
|
||||||
if (from->defbe.be)
|
|
||||||
propagate_processes(from, from->defbe.be);
|
|
||||||
|
|
||||||
/* use_backend */
|
|
||||||
list_for_each_entry(rule, &from->switching_rules, list) {
|
|
||||||
if (rule->dynamic)
|
|
||||||
continue;
|
|
||||||
to = rule->be.backend;
|
|
||||||
propagate_processes(from, to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USE_THREAD) && defined(__linux__) && defined USE_CPU_AFFINITY
|
#if defined(USE_THREAD) && defined(__linux__) && defined USE_CPU_AFFINITY
|
||||||
/* filter directory name of the pattern node<X> */
|
/* filter directory name of the pattern node<X> */
|
||||||
static int numa_filter(const struct dirent *dir)
|
static int numa_filter(const struct dirent *dir)
|
||||||
@ -2687,7 +2633,6 @@ int check_config_validity()
|
|||||||
struct sticking_rule *mrule;
|
struct sticking_rule *mrule;
|
||||||
struct logsrv *tmplogsrv;
|
struct logsrv *tmplogsrv;
|
||||||
unsigned int next_id;
|
unsigned int next_id;
|
||||||
int nbproc;
|
|
||||||
|
|
||||||
if (curproxy->uuid < 0) {
|
if (curproxy->uuid < 0) {
|
||||||
/* proxy ID not set, use automatic numbering with first
|
/* proxy ID not set, use automatic numbering with first
|
||||||
@ -2712,21 +2657,6 @@ int check_config_validity()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check multi-process mode compatibility for the current proxy */
|
|
||||||
|
|
||||||
if (curproxy->bind_proc) {
|
|
||||||
/* an explicit bind-process was specified, let's check how many
|
|
||||||
* processes remain.
|
|
||||||
*/
|
|
||||||
nbproc = my_popcountl(curproxy->bind_proc);
|
|
||||||
|
|
||||||
curproxy->bind_proc &= 1;
|
|
||||||
if (!curproxy->bind_proc && nbproc == 1) {
|
|
||||||
ha_warning("Proxy '%s': the process specified on the 'bind-process' directive refers to a process number that is higher than global.nbproc. The proxy has been forced to run on process 1 only.\n", curproxy->id);
|
|
||||||
curproxy->bind_proc = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check and reduce the bind-proc of each listener */
|
/* check and reduce the bind-proc of each listener */
|
||||||
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
||||||
unsigned long mask;
|
unsigned long mask;
|
||||||
@ -2769,25 +2699,6 @@ int check_config_validity()
|
|||||||
ha_warning("Proxy '%s': the thread range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to thread numbers out of the range defined by the global 'nbthread' directive. The thread numbers were remapped to existing threads instead (mask 0x%lx).\n",
|
ha_warning("Proxy '%s': the thread range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to thread numbers out of the range defined by the global 'nbthread' directive. The thread numbers were remapped to existing threads instead (mask 0x%lx).\n",
|
||||||
curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line, new_mask);
|
curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line, new_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* detect process and nbproc affinity inconsistencies */
|
|
||||||
mask = proc_mask(bind_conf->settings.bind_proc) & proc_mask(curproxy->bind_proc);
|
|
||||||
if (!(mask & 1)) {
|
|
||||||
mask = proc_mask(curproxy->bind_proc) & 1;
|
|
||||||
nbproc = my_popcountl(bind_conf->settings.bind_proc);
|
|
||||||
bind_conf->settings.bind_proc = proc_mask(bind_conf->settings.bind_proc) & mask;
|
|
||||||
|
|
||||||
if (!bind_conf->settings.bind_proc && nbproc == 1) {
|
|
||||||
ha_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->settings.bind_proc = mask & ~(mask - 1);
|
|
||||||
}
|
|
||||||
else if (!bind_conf->settings.bind_proc && nbproc > 1) {
|
|
||||||
ha_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->settings.bind_proc = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (curproxy->mode) {
|
switch (curproxy->mode) {
|
||||||
@ -3114,11 +3025,6 @@ int check_config_validity()
|
|||||||
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
|
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
|
||||||
cfgerr++;
|
cfgerr++;
|
||||||
}
|
}
|
||||||
else if (target->proxy && curproxy->bind_proc & ~target->proxy->bind_proc) {
|
|
||||||
ha_alert("Proxy '%s': stick-table '%s' referenced 'stick-store' rule not present on all processes covered by proxy '%s'.\n",
|
|
||||||
curproxy->id, target->id, curproxy->id);
|
|
||||||
cfgerr++;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
ha_free(&mrule->table.name);
|
ha_free(&mrule->table.name);
|
||||||
mrule->table.t = target;
|
mrule->table.t = target;
|
||||||
@ -3153,11 +3059,6 @@ int check_config_validity()
|
|||||||
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
|
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
|
||||||
cfgerr++;
|
cfgerr++;
|
||||||
}
|
}
|
||||||
else if (target->proxy && (curproxy->bind_proc & ~target->proxy->bind_proc)) {
|
|
||||||
ha_alert("Proxy '%s': stick-table '%s' referenced 'stick-store' rule not present on all processes covered by proxy '%s'.\n",
|
|
||||||
curproxy->id, target->id, curproxy->id);
|
|
||||||
cfgerr++;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
ha_free(&mrule->table.name);
|
ha_free(&mrule->table.name);
|
||||||
mrule->table.t = target;
|
mrule->table.t = target;
|
||||||
@ -3982,50 +3883,6 @@ int check_config_validity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check multi-process mode compatibility */
|
|
||||||
|
|
||||||
/* Make each frontend inherit bind-process from its listeners when not specified. */
|
|
||||||
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
|
|
||||||
if (curproxy->bind_proc)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
|
||||||
unsigned long mask;
|
|
||||||
|
|
||||||
mask = proc_mask(bind_conf->settings.bind_proc);
|
|
||||||
curproxy->bind_proc |= mask;
|
|
||||||
}
|
|
||||||
curproxy->bind_proc = proc_mask(curproxy->bind_proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global.cli_fe) {
|
|
||||||
list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
|
|
||||||
unsigned long mask;
|
|
||||||
|
|
||||||
mask = bind_conf->settings.bind_proc ? bind_conf->settings.bind_proc : 0;
|
|
||||||
global.cli_fe->bind_proc |= mask;
|
|
||||||
}
|
|
||||||
global.cli_fe->bind_proc = proc_mask(global.cli_fe->bind_proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* propagate bindings from frontends to backends. Don't do it if there
|
|
||||||
* are any fatal errors as we must not call it with unresolved proxies.
|
|
||||||
*/
|
|
||||||
if (!cfgerr) {
|
|
||||||
for (curproxy = proxies_list; 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 = proxies_list; curproxy; curproxy = curproxy->next)
|
|
||||||
curproxy->bind_proc = proc_mask(curproxy->bind_proc);
|
|
||||||
|
|
||||||
/*******************************************************/
|
|
||||||
/* At this step, all proxies have a non-null bind_proc */
|
|
||||||
/*******************************************************/
|
|
||||||
|
|
||||||
/* perform the final checks before creating tasks */
|
/* perform the final checks before creating tasks */
|
||||||
|
|
||||||
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
|
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
|
||||||
@ -4045,14 +3902,6 @@ int check_config_validity()
|
|||||||
/* adjust this proxy's listeners */
|
/* adjust this proxy's listeners */
|
||||||
next_id = 1;
|
next_id = 1;
|
||||||
list_for_each_entry(listener, &curproxy->conf.listeners, by_fe) {
|
list_for_each_entry(listener, &curproxy->conf.listeners, by_fe) {
|
||||||
int nbproc;
|
|
||||||
|
|
||||||
nbproc = my_popcountl(curproxy->bind_proc &
|
|
||||||
(listener->bind_conf->settings.bind_proc ? listener->bind_conf->settings.bind_proc : curproxy->bind_proc) & 1);
|
|
||||||
|
|
||||||
if (!nbproc) /* no intersection between listener and frontend */
|
|
||||||
nbproc = 1;
|
|
||||||
|
|
||||||
if (!listener->luid) {
|
if (!listener->luid) {
|
||||||
/* listener ID not set, use automatic numbering with first
|
/* listener ID not set, use automatic numbering with first
|
||||||
* spare entry starting with next_luid.
|
* spare entry starting with next_luid.
|
||||||
@ -4075,18 +3924,6 @@ int check_config_validity()
|
|||||||
if (!listener->maxaccept)
|
if (!listener->maxaccept)
|
||||||
listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
|
listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
|
||||||
|
|
||||||
/* we want to have an optimal behaviour on single process mode to
|
|
||||||
* maximize the work at once, but in multi-process we want to keep
|
|
||||||
* some fairness between processes, so we target half of the max
|
|
||||||
* number of events to be balanced over all the processes the proxy
|
|
||||||
* is bound to. Remember that maxaccept = -1 must be kept as it is
|
|
||||||
* used to disable the limit.
|
|
||||||
*/
|
|
||||||
if (listener->maxaccept > 0 && nbproc > 1) {
|
|
||||||
listener->maxaccept = (listener->maxaccept + 1) / 2;
|
|
||||||
listener->maxaccept = (listener->maxaccept + nbproc - 1) / nbproc;
|
|
||||||
}
|
|
||||||
|
|
||||||
listener->accept = session_accept_fd;
|
listener->accept = session_accept_fd;
|
||||||
listener->analysers |= curproxy->fe_req_ana;
|
listener->analysers |= curproxy->fe_req_ana;
|
||||||
listener->default_target = curproxy->default_target;
|
listener->default_target = curproxy->default_target;
|
||||||
@ -4110,32 +3947,6 @@ int check_config_validity()
|
|||||||
bind_conf->xprt->destroy_bind_conf(bind_conf);
|
bind_conf->xprt->destroy_bind_conf(bind_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atleast2(curproxy->bind_proc & 1)) {
|
|
||||||
if (curproxy->uri_auth) {
|
|
||||||
int count, maxproc = 0;
|
|
||||||
|
|
||||||
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
|
||||||
count = my_popcountl(bind_conf->settings.bind_proc);
|
|
||||||
if (count > maxproc)
|
|
||||||
maxproc = count;
|
|
||||||
}
|
|
||||||
/* backends have 0, frontends have 1 or more */
|
|
||||||
if (maxproc != 1)
|
|
||||||
ha_warning("Proxy '%s': in multi-process mode, stats will be"
|
|
||||||
" limited to process assigned to the current request.\n",
|
|
||||||
curproxy->id);
|
|
||||||
|
|
||||||
if (!LIST_ISEMPTY(&curproxy->uri_auth->admin_rules)) {
|
|
||||||
ha_warning("Proxy '%s': stats admin will not work correctly in multi-process mode.\n",
|
|
||||||
curproxy->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!LIST_ISEMPTY(&curproxy->sticking_rules)) {
|
|
||||||
ha_warning("Proxy '%s': sticking rules will not work correctly in multi-process mode.\n",
|
|
||||||
curproxy->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create the task associated with the proxy */
|
/* create the task associated with the proxy */
|
||||||
curproxy->task = task_new(MAX_THREADS_MASK);
|
curproxy->task = task_new(MAX_THREADS_MASK);
|
||||||
if (curproxy->task) {
|
if (curproxy->task) {
|
||||||
@ -4164,40 +3975,10 @@ int check_config_validity()
|
|||||||
global.last_checks |= cfg_opts2[optnum].checks;
|
global.last_checks |= cfg_opts2[optnum].checks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute the required process bindings for the peers */
|
|
||||||
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next)
|
|
||||||
if (curproxy->table && curproxy->table->peers.p)
|
|
||||||
curproxy->table->peers.p->peers_fe->bind_proc |= curproxy->bind_proc;
|
|
||||||
|
|
||||||
/* compute the required process bindings for the peers from <stktables_list>
|
|
||||||
* for all the stick-tables, the ones coming with "peers" sections included.
|
|
||||||
*/
|
|
||||||
for (t = stktables_list; t; t = t->next) {
|
|
||||||
struct proxy *p;
|
|
||||||
|
|
||||||
for (p = t->proxies_list; p; p = p->next_stkt_ref) {
|
|
||||||
if (t->peers.p && t->peers.p->peers_fe) {
|
|
||||||
t->peers.p->peers_fe->bind_proc |= p->bind_proc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg_peers) {
|
if (cfg_peers) {
|
||||||
struct peers *curpeers = cfg_peers, **last;
|
struct peers *curpeers = cfg_peers, **last;
|
||||||
struct peer *p, *pb;
|
struct peer *p, *pb;
|
||||||
|
|
||||||
/* In the case the peers frontend was not initialized by a
|
|
||||||
stick-table used in the configuration, set its bind_proc
|
|
||||||
by default to the first process. */
|
|
||||||
while (curpeers) {
|
|
||||||
if (curpeers->peers_fe) {
|
|
||||||
if (curpeers->peers_fe->bind_proc == 0)
|
|
||||||
curpeers->peers_fe->bind_proc = 1;
|
|
||||||
}
|
|
||||||
curpeers = curpeers->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
curpeers = cfg_peers;
|
|
||||||
/* Remove all peers sections which don't have a valid listener,
|
/* Remove all peers sections which don't have a valid listener,
|
||||||
* which are not used by any table, or which are bound to more
|
* which are not used by any table, or which are bound to more
|
||||||
* than one process.
|
* than one process.
|
||||||
@ -4220,18 +4001,6 @@ int check_config_validity()
|
|||||||
stop_proxy(curpeers->peers_fe);
|
stop_proxy(curpeers->peers_fe);
|
||||||
curpeers->peers_fe = NULL;
|
curpeers->peers_fe = NULL;
|
||||||
}
|
}
|
||||||
else if (atleast2(curpeers->peers_fe->bind_proc)) {
|
|
||||||
/* either it's totally stopped or too much used */
|
|
||||||
if (curpeers->peers_fe->bind_proc) {
|
|
||||||
ha_alert("Peers section '%s': peers referenced by sections "
|
|
||||||
"running in different processes (%d different ones). "
|
|
||||||
"Check global.nbproc and all tables' bind-process "
|
|
||||||
"settings.\n", curpeers->id, my_popcountl(curpeers->peers_fe->bind_proc));
|
|
||||||
cfgerr++;
|
|
||||||
}
|
|
||||||
stop_proxy(curpeers->peers_fe);
|
|
||||||
curpeers->peers_fe = NULL;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
/* Initializes the transport layer of the server part of all the peers belonging to
|
/* Initializes the transport layer of the server part of all the peers belonging to
|
||||||
* <curpeers> section if required.
|
* <curpeers> section if required.
|
||||||
|
20
src/cli.c
20
src/cli.c
@ -543,13 +543,12 @@ static int cli_parse_global(char **args, int section_type, struct proxy *curpx,
|
|||||||
set = 0;
|
set = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (parse_process_number(args[cur_arg], &set, MAX_PROCS, NULL, err)) {
|
if (parse_process_number(args[cur_arg], &set, 1, NULL, err)) {
|
||||||
memprintf(err, "'%s %s' : %s", args[0], args[1], *err);
|
memprintf(err, "'%s %s' : %s", args[0], args[1], *err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cur_arg++;
|
cur_arg++;
|
||||||
}
|
}
|
||||||
global.cli_fe->bind_proc = set;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memprintf(err, "'%s' only supports 'socket', 'maxconn', 'bind-process' and 'timeout' (got '%s')", args[0], args[1]);
|
memprintf(err, "'%s' only supports 'socket', 'maxconn', 'bind-process' and 'timeout' (got '%s')", args[0], args[1]);
|
||||||
@ -1526,19 +1525,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
|
|||||||
else
|
else
|
||||||
chunk_appendf(&trash, " ");
|
chunk_appendf(&trash, " ");
|
||||||
|
|
||||||
if (bind_conf->settings.bind_proc != 0) {
|
chunk_appendf(&trash, "all\n");
|
||||||
int pos;
|
|
||||||
for (pos = 0; pos < 8 * sizeof(bind_conf->settings.bind_proc); pos++) {
|
|
||||||
if (bind_conf->settings.bind_proc & (1UL << pos)) {
|
|
||||||
chunk_appendf(&trash, "%d,", pos+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* replace the latest comma by a newline */
|
|
||||||
trash.area[trash.data-1] = '\n';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
chunk_appendf(&trash, "all\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||||
si_rx_room_blk(si);
|
si_rx_room_blk(si);
|
||||||
@ -2917,9 +2904,6 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
|
|||||||
bind_conf->level &= ~ACCESS_LVL_MASK;
|
bind_conf->level &= ~ACCESS_LVL_MASK;
|
||||||
bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/
|
bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/
|
||||||
|
|
||||||
bind_conf->settings.bind_proc = 1UL << proc;
|
|
||||||
global.cli_fe->bind_proc = 0; /* XXX: we should be careful with that, it can be removed by configuration */
|
|
||||||
|
|
||||||
if (!memprintf(&path, "sockpair@%d", mworker_proc->ipc_fd[1])) {
|
if (!memprintf(&path, "sockpair@%d", mworker_proc->ipc_fd[1])) {
|
||||||
ha_alert("Cannot allocate listener.\n");
|
ha_alert("Cannot allocate listener.\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -3072,14 +3072,6 @@ spoe_check(struct proxy *px, struct flt_conf *fconf)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px->bind_proc & ~target->bind_proc) {
|
|
||||||
ha_alert("Proxy %s : backend '%s' used by SPOE agent '%s' declared"
|
|
||||||
" at %s:%d does not cover all of its processes.\n",
|
|
||||||
px->id, target->id, conf->agent->id,
|
|
||||||
conf->agent->conf.file, conf->agent->conf.line);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((conf->agent->rt = calloc(global.nbthread, sizeof(*conf->agent->rt))) == NULL) {
|
if ((conf->agent->rt = calloc(global.nbthread, sizeof(*conf->agent->rt))) == NULL) {
|
||||||
ha_alert("Proxy %s : out of memory initializing SPOE agent '%s' declared at %s:%d.\n",
|
ha_alert("Proxy %s : out of memory initializing SPOE agent '%s' declared at %s:%d.\n",
|
||||||
px->id, conf->agent->id, conf->agent->conf.file, conf->agent->conf.line);
|
px->id, conf->agent->id, conf->agent->conf.file, conf->agent->conf.line);
|
||||||
|
@ -3116,8 +3116,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (global.mode & (MODE_DAEMON | MODE_MWORKER | MODE_MWORKER_WAIT)) {
|
if (global.mode & (MODE_DAEMON | MODE_MWORKER | MODE_MWORKER_WAIT)) {
|
||||||
struct proxy *px;
|
|
||||||
struct peers *curpeers;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int in_parent = 0;
|
int in_parent = 0;
|
||||||
int devnullfd = -1;
|
int devnullfd = -1;
|
||||||
@ -3301,52 +3299,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
|
list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
|
||||||
if (bind_conf->level & ACCESS_FD_LISTENERS) {
|
if (bind_conf->level & ACCESS_FD_LISTENERS) {
|
||||||
if (!bind_conf->settings.bind_proc || bind_conf->settings.bind_proc & 1UL) {
|
global.tune.options |= GTUNE_SOCKET_TRANSFER;
|
||||||
global.tune.options |= GTUNE_SOCKET_TRANSFER;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we might have to unbind some proxies from some processes */
|
|
||||||
px = proxies_list;
|
|
||||||
while (px != NULL) {
|
|
||||||
if (px->bind_proc && !px->disabled) {
|
|
||||||
if (!(px->bind_proc & 1UL))
|
|
||||||
stop_proxy(px);
|
|
||||||
}
|
|
||||||
px = px->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we might have to unbind some log forward proxies from some processes */
|
|
||||||
px = cfg_log_forward;
|
|
||||||
while (px != NULL) {
|
|
||||||
if (px->bind_proc && !px->disabled) {
|
|
||||||
if (!(px->bind_proc & 1UL))
|
|
||||||
stop_proxy(px);
|
|
||||||
}
|
|
||||||
px = px->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we might have to unbind some peers sections from some processes */
|
|
||||||
for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
|
|
||||||
if (!curpeers->peers_fe)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curpeers->peers_fe->bind_proc & 1UL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
stop_proxy(curpeers->peers_fe);
|
|
||||||
/* disable this peer section so that it kills itself */
|
|
||||||
signal_unregister_handler(curpeers->sighandler);
|
|
||||||
task_destroy(curpeers->sync_task);
|
|
||||||
curpeers->sync_task = NULL;
|
|
||||||
task_destroy(curpeers->peers_fe->task);
|
|
||||||
curpeers->peers_fe->task = NULL;
|
|
||||||
curpeers->peers_fe = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is only done in daemon mode because we might want the
|
* This is only done in daemon mode because we might want the
|
||||||
* logs on stdout in mworker mode. If we're NOT in QUIET mode,
|
* logs on stdout in mworker mode. If we're NOT in QUIET mode,
|
||||||
|
@ -276,8 +276,7 @@ void enable_listener(struct listener *listener)
|
|||||||
if (listener->state == LI_LISTEN) {
|
if (listener->state == LI_LISTEN) {
|
||||||
BUG_ON(listener->rx.fd == -1);
|
BUG_ON(listener->rx.fd == -1);
|
||||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
||||||
(!!master != !!(listener->rx.flags & RX_F_MWORKER) ||
|
(!!master != !!(listener->rx.flags & RX_F_MWORKER))) {
|
||||||
!(proc_mask(listener->rx.settings->bind_proc) & 1))) {
|
|
||||||
/* we don't want to enable this listener and don't
|
/* we don't want to enable this listener and don't
|
||||||
* want any fd event to reach it.
|
* want any fd event to reach it.
|
||||||
*/
|
*/
|
||||||
@ -430,10 +429,6 @@ int pause_listener(struct listener *l)
|
|||||||
|
|
||||||
HA_SPIN_LOCK(LISTENER_LOCK, &l->lock);
|
HA_SPIN_LOCK(LISTENER_LOCK, &l->lock);
|
||||||
|
|
||||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
|
||||||
!(proc_mask(l->rx.settings->bind_proc) & 1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (l->state <= LI_PAUSED)
|
if (l->state <= LI_PAUSED)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
@ -477,10 +472,6 @@ int resume_listener(struct listener *l)
|
|||||||
if (MT_LIST_INLIST(&l->wait_queue))
|
if (MT_LIST_INLIST(&l->wait_queue))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
|
||||||
!(proc_mask(l->rx.settings->bind_proc) & 1))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (l->state == LI_READY)
|
if (l->state == LI_READY)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
@ -1499,7 +1490,7 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct
|
|||||||
if ((slash = strchr(args[cur_arg + 1], '/')) != NULL)
|
if ((slash = strchr(args[cur_arg + 1], '/')) != NULL)
|
||||||
*slash = 0;
|
*slash = 0;
|
||||||
|
|
||||||
if (parse_process_number(args[cur_arg + 1], &proc, MAX_PROCS, NULL, err)) {
|
if (parse_process_number(args[cur_arg + 1], &proc, 1, NULL, err)) {
|
||||||
memprintf(err, "'%s' : %s", args[cur_arg], *err);
|
memprintf(err, "'%s' : %s", args[cur_arg], *err);
|
||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
@ -1512,7 +1503,6 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct
|
|||||||
*slash = '/';
|
*slash = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->settings.bind_proc |= proc;
|
|
||||||
conf->settings.bind_thread |= thread;
|
conf->settings.bind_thread |= thread;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2864,7 +2864,6 @@ void peers_setup_frontend(struct proxy *fe)
|
|||||||
fe->accept = frontend_accept;
|
fe->accept = frontend_accept;
|
||||||
fe->default_target = &peer_applet.obj_type;
|
fe->default_target = &peer_applet.obj_type;
|
||||||
fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
|
fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
|
||||||
fe->bind_proc = 0; /* will be filled by users */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
13
src/proxy.c
13
src/proxy.c
@ -1515,7 +1515,6 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro
|
|||||||
curproxy->options2 = defproxy->options2;
|
curproxy->options2 = defproxy->options2;
|
||||||
curproxy->no_options = defproxy->no_options;
|
curproxy->no_options = defproxy->no_options;
|
||||||
curproxy->no_options2 = defproxy->no_options2;
|
curproxy->no_options2 = defproxy->no_options2;
|
||||||
curproxy->bind_proc = defproxy->bind_proc;
|
|
||||||
curproxy->except_xff_net = defproxy->except_xff_net;
|
curproxy->except_xff_net = defproxy->except_xff_net;
|
||||||
curproxy->except_xot_net = defproxy->except_xot_net;
|
curproxy->except_xot_net = defproxy->except_xot_net;
|
||||||
curproxy->retry_type = defproxy->retry_type;
|
curproxy->retry_type = defproxy->retry_type;
|
||||||
@ -1794,9 +1793,6 @@ void proxy_cond_disable(struct proxy *p)
|
|||||||
|
|
||||||
p->disabled = 1;
|
p->disabled = 1;
|
||||||
|
|
||||||
if (!(proc_mask(p->bind_proc) & 1))
|
|
||||||
goto silent;
|
|
||||||
|
|
||||||
/* Note: syslog proxies use their own loggers so while it's somewhat OK
|
/* Note: syslog proxies use their own loggers so while it's somewhat OK
|
||||||
* to report them being stopped as a warning, we must not spam their log
|
* to report them being stopped as a warning, we must not spam their log
|
||||||
* servers which are in fact production servers. For other types (CLI,
|
* servers which are in fact production servers. For other types (CLI,
|
||||||
@ -1811,7 +1807,6 @@ void proxy_cond_disable(struct proxy *p)
|
|||||||
send_log(p, LOG_WARNING, "Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
|
send_log(p, LOG_WARNING, "Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
|
||||||
p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
||||||
|
|
||||||
silent:
|
|
||||||
if (p->table && p->table->size && p->table->sync_task)
|
if (p->table && p->table->size && p->table->sync_task)
|
||||||
task_wakeup(p->table->sync_task, TASK_WOKEN_MSG);
|
task_wakeup(p->table->sync_task, TASK_WOKEN_MSG);
|
||||||
|
|
||||||
@ -2474,10 +2469,6 @@ static int dump_servers_state(struct stream_interface *si)
|
|||||||
int bk_f_forced_id, srv_f_forced_id;
|
int bk_f_forced_id, srv_f_forced_id;
|
||||||
char *srvrecord;
|
char *srvrecord;
|
||||||
|
|
||||||
/* we don't want to report any state if the backend is not enabled on this process */
|
|
||||||
if (!(proc_mask(px->bind_proc) & 1))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!appctx->ctx.cli.p1)
|
if (!appctx->ctx.cli.p1)
|
||||||
appctx->ctx.cli.p1 = px->srv;
|
appctx->ctx.cli.p1 = px->srv;
|
||||||
|
|
||||||
@ -2613,10 +2604,6 @@ static int cli_io_handler_show_backend(struct appctx *appctx)
|
|||||||
if (!(curproxy->cap & PR_CAP_BE))
|
if (!(curproxy->cap & PR_CAP_BE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* we don't want to list a backend which is bound to this process */
|
|
||||||
if (!(proc_mask(curproxy->bind_proc) & 1))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
chunk_appendf(&trash, "%s\n", curproxy->id);
|
chunk_appendf(&trash, "%s\n", curproxy->id);
|
||||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||||
si_rx_room_blk(si);
|
si_rx_room_blk(si);
|
||||||
|
@ -3014,7 +3014,6 @@ void resolvers_setup_proxy(struct proxy *px)
|
|||||||
px->timeout.connect = TICK_ETERNITY;
|
px->timeout.connect = TICK_ETERNITY;
|
||||||
px->accept = NULL;
|
px->accept = NULL;
|
||||||
px->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON;
|
px->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON;
|
||||||
px->bind_proc = 0; /* will be filled by users */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1296,13 +1296,6 @@ int smp_resolve_args(struct proxy *p, char **err)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->proxy && (p->bind_proc & ~t->proxy->bind_proc)) {
|
|
||||||
memprintf(err, "%sparsing [%s:%d]: stick-table '%s' not present on all processes covered by proxy '%s'.\n",
|
|
||||||
*err ? *err : "", cur->file, cur->line, t->proxy->id, p->id);
|
|
||||||
cfgerr++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_proxies_list(t->proxies_list, p)) {
|
if (!in_proxies_list(t->proxies_list, p)) {
|
||||||
p->next_stkt_ref = t->proxies_list;
|
p->next_stkt_ref = t->proxies_list;
|
||||||
t->proxies_list = p;
|
t->proxies_list = p;
|
||||||
|
@ -287,7 +287,6 @@ void sink_setup_proxy(struct proxy *px)
|
|||||||
px->timeout.connect = TICK_ETERNITY;
|
px->timeout.connect = TICK_ETERNITY;
|
||||||
px->accept = NULL;
|
px->accept = NULL;
|
||||||
px->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
|
px->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
|
||||||
px->bind_proc = 0; /* will be filled by users */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user