]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: global: remove pid_bit and all_proc_mask
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 06:13:20 +0000 (08:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 14:52:42 +0000 (16:52 +0200)
They were already set to 1 and never changed. Let's remove them and
replace their references with 1.

include/haproxy/global.h
src/cfgparse.c
src/haproxy.c
src/listener.c
src/proxy.c

index 515963646dac0d022ae2167d7010900fe5636030..274ec340a55db4c61684235f8d6af63b0601cbb6 100644 (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 */
index 3011f655ead9297c96493ffe5c8cc5c9b87edc6a..1bac73bd194f4ecbdb1b7df732dbd996d466b50f 100644 (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;
 
index 26c70bdfff0e9ff4cb2a728f9830d86311f11d84..ecce3de4282d16c74958b1ace1260f9f032885eb 100644 (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;
index 8031c750697d9df076cee387fda23c0aeda884bd..e90d37c6fe13ba7c0c366fafd7a15a2f40ce8d81 100644 (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)
index 6d0219359f06a1cb45d24559259cc61a8f0a835d..6a1cfa032ee93b86a24560cfa19828f0c04ec615 100644 (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);