mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: listener: move bind_proc and bind_thread to struct settings
As mentioned previously, these two fields come under the settings struct since they'll be used to bind receivers as well.
This commit is contained in:
parent
6e459d7f92
commit
e26993c098
@ -173,14 +173,14 @@ struct bind_conf {
|
||||
int level; /* stats access level (ACCESS_LVL_*) */
|
||||
int severity_output; /* default severity output format in cli feedback messages */
|
||||
struct list listeners; /* list of listeners using this bind config */
|
||||
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
|
||||
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
|
||||
uint32_t ns_cip_magic; /* Excepted NetScaler Client IP magic number */
|
||||
struct list by_fe; /* next binding for the same frontend, or NULL */
|
||||
char *arg; /* argument passed to "bind" for better error reporting */
|
||||
char *file; /* file where the section appears */
|
||||
int line; /* line where the section appears */
|
||||
struct {
|
||||
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
|
||||
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
|
||||
struct { /* UNIX socket permissions */
|
||||
uid_t uid; /* -1 to leave unchanged */
|
||||
gid_t gid; /* -1 to leave unchanged */
|
||||
|
@ -2323,7 +2323,7 @@ int check_config_validity()
|
||||
#endif
|
||||
|
||||
/* detect and address thread affinity inconsistencies */
|
||||
mask = thread_mask(bind_conf->bind_thread);
|
||||
mask = thread_mask(bind_conf->settings.bind_thread);
|
||||
if (!(mask & all_threads_mask)) {
|
||||
unsigned long new_mask = 0;
|
||||
|
||||
@ -2332,27 +2332,27 @@ int check_config_validity()
|
||||
mask >>= global.nbthread;
|
||||
}
|
||||
|
||||
bind_conf->bind_thread = new_mask;
|
||||
bind_conf->settings.bind_thread = new_mask;
|
||||
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);
|
||||
}
|
||||
|
||||
/* detect process and nbproc affinity inconsistencies */
|
||||
mask = proc_mask(bind_conf->bind_proc) & proc_mask(curproxy->bind_proc);
|
||||
mask = proc_mask(bind_conf->settings.bind_proc) & proc_mask(curproxy->bind_proc);
|
||||
if (!(mask & all_proc_mask)) {
|
||||
mask = proc_mask(curproxy->bind_proc) & all_proc_mask;
|
||||
nbproc = my_popcountl(bind_conf->bind_proc);
|
||||
bind_conf->bind_proc = proc_mask(bind_conf->bind_proc) & mask;
|
||||
nbproc = my_popcountl(bind_conf->settings.bind_proc);
|
||||
bind_conf->settings.bind_proc = proc_mask(bind_conf->settings.bind_proc) & mask;
|
||||
|
||||
if (!bind_conf->bind_proc && nbproc == 1) {
|
||||
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->bind_proc = mask & ~(mask - 1);
|
||||
bind_conf->settings.bind_proc = mask & ~(mask - 1);
|
||||
}
|
||||
else if (!bind_conf->bind_proc && nbproc > 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->bind_proc = 0;
|
||||
bind_conf->settings.bind_proc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3641,7 +3641,7 @@ int check_config_validity()
|
||||
unsigned long mask;
|
||||
|
||||
mask = proc_mask(global.stats_fe->bind_proc) && all_proc_mask;
|
||||
mask &= proc_mask(bind_conf->bind_proc);
|
||||
mask &= proc_mask(bind_conf->settings.bind_proc);
|
||||
|
||||
/* stop here if more than one process is used */
|
||||
if (atleast2(mask))
|
||||
@ -3660,7 +3660,7 @@ int check_config_validity()
|
||||
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
||||
unsigned long mask;
|
||||
|
||||
mask = proc_mask(bind_conf->bind_proc);
|
||||
mask = proc_mask(bind_conf->settings.bind_proc);
|
||||
curproxy->bind_proc |= mask;
|
||||
}
|
||||
curproxy->bind_proc = proc_mask(curproxy->bind_proc);
|
||||
@ -3670,7 +3670,7 @@ int check_config_validity()
|
||||
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 : 0;
|
||||
mask = bind_conf->settings.bind_proc ? bind_conf->settings.bind_proc : 0;
|
||||
global.stats_fe->bind_proc |= mask;
|
||||
}
|
||||
global.stats_fe->bind_proc = proc_mask(global.stats_fe->bind_proc);
|
||||
@ -3716,7 +3716,7 @@ int check_config_validity()
|
||||
int nbproc;
|
||||
|
||||
nbproc = my_popcountl(curproxy->bind_proc &
|
||||
(listener->bind_conf->bind_proc ? listener->bind_conf->bind_proc : curproxy->bind_proc) &
|
||||
(listener->bind_conf->settings.bind_proc ? listener->bind_conf->settings.bind_proc : curproxy->bind_proc) &
|
||||
all_proc_mask);
|
||||
|
||||
if (!nbproc) /* no intersection between listener and frontend */
|
||||
@ -3787,7 +3787,7 @@ int check_config_validity()
|
||||
int count, maxproc = 0;
|
||||
|
||||
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
|
||||
count = my_popcountl(bind_conf->bind_proc);
|
||||
count = my_popcountl(bind_conf->settings.bind_proc);
|
||||
if (count > maxproc)
|
||||
maxproc = count;
|
||||
}
|
||||
|
@ -1270,10 +1270,10 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
|
||||
else
|
||||
chunk_appendf(&trash, " ");
|
||||
|
||||
if (bind_conf->bind_proc != 0) {
|
||||
if (bind_conf->settings.bind_proc != 0) {
|
||||
int pos;
|
||||
for (pos = 0; pos < 8 * sizeof(bind_conf->bind_proc); pos++) {
|
||||
if (bind_conf->bind_proc & (1UL << 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);
|
||||
}
|
||||
}
|
||||
@ -2650,7 +2650,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
|
||||
bind_conf->level &= ~ACCESS_LVL_MASK;
|
||||
bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/
|
||||
|
||||
bind_conf->bind_proc = 1UL << proc;
|
||||
bind_conf->settings.bind_proc = 1UL << proc;
|
||||
global.stats_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])) {
|
||||
|
@ -3464,7 +3464,7 @@ int main(int argc, char **argv)
|
||||
|
||||
list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
|
||||
if (bind_conf->level & ACCESS_FD_LISTENERS) {
|
||||
if (!bind_conf->bind_proc || bind_conf->bind_proc & (1UL << proc)) {
|
||||
if (!bind_conf->settings.bind_proc || bind_conf->settings.bind_proc & (1UL << proc)) {
|
||||
global.tune.options |= GTUNE_SOCKET_TRANSFER;
|
||||
break;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ static void enable_listener(struct listener *listener)
|
||||
HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock);
|
||||
if (listener->state == LI_LISTEN) {
|
||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
||||
!(proc_mask(listener->bind_conf->bind_proc) & pid_bit)) {
|
||||
!(proc_mask(listener->bind_conf->settings.bind_proc) & pid_bit)) {
|
||||
/* we don't want to enable this listener and don't
|
||||
* want any fd event to reach it.
|
||||
*/
|
||||
@ -342,7 +342,7 @@ int resume_listener(struct listener *l)
|
||||
goto end;
|
||||
|
||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
||||
!(proc_mask(l->bind_conf->bind_proc) & pid_bit))
|
||||
!(proc_mask(l->bind_conf->settings.bind_proc) & pid_bit))
|
||||
goto end;
|
||||
|
||||
if (l->state == LI_ASSIGNED) {
|
||||
@ -383,11 +383,11 @@ int resume_listener(struct listener *l)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!(thread_mask(l->bind_conf->bind_thread) & tid_bit)) {
|
||||
if (!(thread_mask(l->bind_conf->settings.bind_thread) & tid_bit)) {
|
||||
/* we're not allowed to touch this listener's FD, let's requeue
|
||||
* the listener into one of its owning thread's queue instead.
|
||||
*/
|
||||
int first_thread = my_flsl(thread_mask(l->bind_conf->bind_thread) & all_threads_mask) - 1;
|
||||
int first_thread = my_flsl(thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask) - 1;
|
||||
work_list_add(&local_listener_queue[first_thread], &l->wait_queue);
|
||||
goto end;
|
||||
}
|
||||
@ -874,7 +874,7 @@ void listener_accept(int fd)
|
||||
next_actconn = 0;
|
||||
|
||||
#if defined(USE_THREAD)
|
||||
mask = thread_mask(l->bind_conf->bind_thread) & all_threads_mask;
|
||||
mask = thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask;
|
||||
if (atleast2(mask) && (global.tune.options & GTUNE_LISTENER_MQ) && !stopping) {
|
||||
struct accept_queue_ring *ring;
|
||||
unsigned int t, t0, t1, t2;
|
||||
@ -1472,8 +1472,8 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
conf->bind_proc |= proc;
|
||||
conf->bind_thread |= thread;
|
||||
conf->settings.bind_proc |= proc;
|
||||
conf->settings.bind_thread |= thread;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
|
||||
listener->state = LI_LISTEN;
|
||||
|
||||
fd_insert(fd, listener, listener->proto->accept,
|
||||
thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
|
||||
thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
|
||||
|
||||
return err;
|
||||
|
||||
|
@ -768,7 +768,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
listener->state = LI_LISTEN;
|
||||
|
||||
fd_insert(fd, listener, listener->proto->accept,
|
||||
thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
|
||||
thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
|
||||
|
||||
/* for now, all regularly bound TCP listeners are exportable */
|
||||
if (!(listener->options & LI_O_INHERITED))
|
||||
|
@ -279,7 +279,7 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
|
||||
if (listener->bind_conf->frontend->mode == PR_MODE_SYSLOG)
|
||||
fd_insert(fd, listener, syslog_fd_handler,
|
||||
thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
|
||||
thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
|
||||
else {
|
||||
err |= ERR_FATAL | ERR_ALERT;
|
||||
msg = "UDP is not yet supported on this proxy mode";
|
||||
|
@ -263,7 +263,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
|
||||
listener->state = LI_LISTEN;
|
||||
|
||||
fd_insert(fd, listener, listener->proto->accept,
|
||||
thread_mask(listener->bind_conf->bind_thread) & all_threads_mask);
|
||||
thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
|
||||
|
||||
/* for now, all regularly bound UNIX listeners are exportable */
|
||||
if (!(listener->options & LI_O_INHERITED))
|
||||
|
Loading…
Reference in New Issue
Block a user