CLEANUP: global: remove pid_bit and all_proc_mask

They were already set to 1 and never changed. Let's remove them and
replace their references with 1.
This commit is contained in:
Willy Tarreau 2021-06-15 08:13:20 +02:00
parent 91358595f8
commit 5301f5d72a
5 changed files with 13 additions and 20 deletions

View File

@ -29,8 +29,6 @@ extern const char *build_features;
extern struct global global;
extern int pid; /* current process id */
extern int relative_pid; /* process id starting at 1 */
extern unsigned long pid_bit; /* bit corresponding to the process id */
extern unsigned long all_proc_mask; /* mask of all processes */
extern int actconn; /* # of active sessions */
extern int listeners;
extern int jobs; /* # of active jobs (listeners, sessions, open devices) */
@ -79,10 +77,10 @@ static inline int already_warned(unsigned int warning)
return 0;
}
/* returns a mask if set, otherwise all_proc_mask */
/* returns a mask if set, otherwise 1 */
static inline unsigned long proc_mask(unsigned long mask)
{
return mask ? mask : all_proc_mask;
return mask ? mask : 1;
}
/* handle 'tainted' status */

View File

@ -2720,7 +2720,7 @@ int check_config_validity()
*/
nbproc = my_popcountl(curproxy->bind_proc);
curproxy->bind_proc &= all_proc_mask;
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;
@ -2772,8 +2772,8 @@ int check_config_validity()
/* detect process and nbproc affinity inconsistencies */
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;
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;
@ -4048,8 +4048,7 @@ out_uri_auth_compat:
int nbproc;
nbproc = my_popcountl(curproxy->bind_proc &
(listener->bind_conf->settings.bind_proc ? listener->bind_conf->settings.bind_proc : curproxy->bind_proc) &
all_proc_mask);
(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;
@ -4111,7 +4110,7 @@ out_uri_auth_compat:
bind_conf->xprt->destroy_bind_conf(bind_conf);
}
if (atleast2(curproxy->bind_proc & all_proc_mask)) {
if (atleast2(curproxy->bind_proc & 1)) {
if (curproxy->uri_auth) {
int count, maxproc = 0;

View File

@ -158,8 +158,6 @@ const char *build_features = "";
static struct list cfg_cfgfiles = LIST_HEAD_INIT(cfg_cfgfiles);
int pid; /* current process id */
int relative_pid = 1; /* process id starting at 1 */
unsigned long pid_bit = 1; /* bit corresponding to the process id */
unsigned long all_proc_mask = 1; /* mask of all processes */
volatile unsigned long sleeping_thread_mask = 0; /* Threads that are about to sleep in poll() */
volatile unsigned long stopping_thread_mask = 0; /* Threads acknowledged stopping */
@ -824,8 +822,6 @@ static void mworker_loop()
global.nbthread = 1;
relative_pid = 1;
pid_bit = 1;
all_proc_mask = 1;
#ifdef USE_THREAD
tid_bit = 1;

View File

@ -277,7 +277,7 @@ void enable_listener(struct listener *listener)
BUG_ON(listener->rx.fd == -1);
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
(!!master != !!(listener->rx.flags & RX_F_MWORKER) ||
!(proc_mask(listener->rx.settings->bind_proc) & pid_bit))) {
!(proc_mask(listener->rx.settings->bind_proc) & 1))) {
/* we don't want to enable this listener and don't
* want any fd event to reach it.
*/
@ -431,7 +431,7 @@ int pause_listener(struct listener *l)
HA_SPIN_LOCK(LISTENER_LOCK, &l->lock);
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
!(proc_mask(l->rx.settings->bind_proc) & pid_bit))
!(proc_mask(l->rx.settings->bind_proc) & 1))
goto end;
if (l->state <= LI_PAUSED)
@ -478,7 +478,7 @@ int resume_listener(struct listener *l)
goto end;
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
!(proc_mask(l->rx.settings->bind_proc) & pid_bit))
!(proc_mask(l->rx.settings->bind_proc) & 1))
goto end;
if (l->state == LI_READY)

View File

@ -1794,7 +1794,7 @@ void proxy_cond_disable(struct proxy *p)
p->disabled = 1;
if (!(proc_mask(p->bind_proc) & pid_bit))
if (!(proc_mask(p->bind_proc) & 1))
goto silent;
/* Note: syslog proxies use their own loggers so while it's somewhat OK
@ -2475,7 +2475,7 @@ static int dump_servers_state(struct stream_interface *si)
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) & pid_bit))
if (!(proc_mask(px->bind_proc) & 1))
return 1;
if (!appctx->ctx.cli.p1)
@ -2614,7 +2614,7 @@ static int cli_io_handler_show_backend(struct appctx *appctx)
continue;
/* we don't want to list a backend which is bound to this process */
if (!(proc_mask(curproxy->bind_proc) & pid_bit))
if (!(proc_mask(curproxy->bind_proc) & 1))
continue;
chunk_appendf(&trash, "%s\n", curproxy->id);