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.
diff --git a/include/haproxy/global.h b/include/haproxy/global.h
index 5159636..274ec34 100644
--- a/include/haproxy/global.h
+++ b/include/haproxy/global.h
@@ -29,8 +29,6 @@
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 @@
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 */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 3011f65..1bac73b 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2720,7 +2720,7 @@
*/
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 @@
/* 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 @@
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 @@
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;
diff --git a/src/haproxy.c b/src/haproxy.c
index 26c70bd..ecce3de 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -158,8 +158,6 @@
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 @@
global.nbthread = 1;
relative_pid = 1;
- pid_bit = 1;
- all_proc_mask = 1;
#ifdef USE_THREAD
tid_bit = 1;
diff --git a/src/listener.c b/src/listener.c
index 8031c75..e90d37c 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -277,7 +277,7 @@
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 @@
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 @@
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)
diff --git a/src/proxy.c b/src/proxy.c
index 6d02193..6a1cfa0 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1794,7 +1794,7 @@
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 @@
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 @@
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);