]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: keep an all_proc_mask like we have all_threads_mask
authorWilly Tarreau <w@1wt.eu>
Sat, 2 Feb 2019 16:11:28 +0000 (17:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 4 Feb 2019 04:09:15 +0000 (05:09 +0100)
This simplifies some mask comparisons at various places where
nbits(global.nbproc) was used.

include/types/global.h
src/cfgparse-global.c
src/cfgparse.c
src/haproxy.c

index 16fce723ef157ea17e0c2231e854ea43d1d2d4e0..879273a929827d6db086912841d0ac76b5c1e993 100644 (file)
@@ -198,6 +198,7 @@ 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) */
index 2cdcf76616db3a9a643612b09a657dfae3e7cb97..820c7b6a0635932a8f789af897481866280d149b 100644 (file)
@@ -489,6 +489,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
                global.nbproc = atol(args[1]);
+               all_proc_mask = nbits(global.nbproc);
                if (global.nbproc < 1 || global.nbproc > LONGBITS) {
                        ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
                                 file, linenum, args[0], LONGBITS, global.nbproc);
index 40a21e784171cda8b3ce48f9154f090215750271..441f4a6a0c4972e069ee0cbf8258808cf89abcd0 100644 (file)
@@ -2246,7 +2246,7 @@ int check_config_validity()
                         */
                        nbproc = my_popcountl(curproxy->bind_proc);
 
-                       curproxy->bind_proc &= nbits(global.nbproc);
+                       curproxy->bind_proc &= all_proc_mask;
                        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;
@@ -2311,7 +2311,7 @@ int check_config_validity()
                        if (!bind_conf->bind_proc)
                                continue;
 
-                       mask = nbits(global.nbproc);
+                       mask = all_proc_mask;
                        if (curproxy->bind_proc)
                                mask &= curproxy->bind_proc;
                        /* mask cannot be null here thanks to the previous checks */
@@ -3550,7 +3550,7 @@ out_uri_auth_compat:
                list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
                        unsigned long mask;
 
-                       mask = nbits(global.nbproc);
+                       mask = all_proc_mask;
                        if (global.stats_fe->bind_proc)
                                mask &= global.stats_fe->bind_proc;
 
@@ -3574,12 +3574,12 @@ out_uri_auth_compat:
                list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
                        unsigned long mask;
 
-                       mask = bind_conf->bind_proc ? bind_conf->bind_proc : nbits(global.nbproc);
+                       mask = bind_conf->bind_proc ? bind_conf->bind_proc : all_proc_mask;
                        curproxy->bind_proc |= mask;
                }
 
                if (!curproxy->bind_proc)
-                       curproxy->bind_proc = nbits(global.nbproc);
+                       curproxy->bind_proc = all_proc_mask;
        }
 
        if (global.stats_fe) {
@@ -3590,7 +3590,7 @@ out_uri_auth_compat:
                        global.stats_fe->bind_proc |= mask;
                }
                if (!global.stats_fe->bind_proc)
-                       global.stats_fe->bind_proc = nbits(global.nbproc);
+                       global.stats_fe->bind_proc = all_proc_mask;
        }
 
        /* propagate bindings from frontends to backends. Don't do it if there
@@ -3607,7 +3607,7 @@ out_uri_auth_compat:
        for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
                if (curproxy->bind_proc)
                        continue;
-               curproxy->bind_proc = nbits(global.nbproc);
+               curproxy->bind_proc = all_proc_mask;
        }
 
        /*******************************************************/
@@ -3637,7 +3637,7 @@ out_uri_auth_compat:
 
                        nbproc = my_popcountl(curproxy->bind_proc &
                                              (listener->bind_conf->bind_proc ? listener->bind_conf->bind_proc : curproxy->bind_proc) &
-                                             nbits(global.nbproc));
+                                             all_proc_mask);
 
                        if (!nbproc) /* no intersection between listener and frontend */
                                nbproc = 1;
@@ -3707,7 +3707,7 @@ out_uri_auth_compat:
                                bind_conf->xprt->destroy_bind_conf(bind_conf);
                }
 
-               if (atleast2(curproxy->bind_proc & nbits(global.nbproc))) {
+               if (atleast2(curproxy->bind_proc & all_proc_mask)) {
                        if (curproxy->uri_auth) {
                                int count, maxproc = 0;
 
index 5a69086546850471893a9da84c78d52ce781d995..ce4cde3111ad7e39749dac0e059406b4922c6fbf 100644 (file)
@@ -129,6 +129,7 @@ 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; /* Threads that are about to sleep in poll() */
 /* global options */
@@ -903,6 +904,7 @@ static void mworker_loop()
        global.nbthread = 1;
        relative_pid = 1;
        pid_bit = 1;
+       all_proc_mask = 1;
 
 #ifdef USE_THREAD
        tid_bit = 1;