]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: global: remove the nbproc field from the global structure
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 06:08:04 +0000 (08:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 14:52:42 +0000 (16:52 +0200)
Let's use 1 in the rare places where it was still referenced since it's
now its only possible value.

include/haproxy/global-t.h
src/haproxy.c
src/sample.c
src/ssl_sock.c
src/stats.c

index 057d90e6185ca3fdb174e306388025b857c1b209..b5ecc553aa056e672c7240aa82b932dbc669868e 100644 (file)
@@ -90,7 +90,6 @@ struct global {
        int uid;
        int gid;
        int external_check;
-       int nbproc;
        int nbthread;
        int mode;
        unsigned int hard_stop_after;   /* maximum time allowed to perform a soft-stop */
index c4f2c9be8c4c53dc4bdd6e67f3022c05046c70da..26c70bdfff0e9ff4cb2a728f9830d86311f11d84 100644 (file)
@@ -167,7 +167,6 @@ volatile unsigned long stopping_thread_mask = 0; /* Threads acknowledged stoppin
 /* global options */
 struct global global = {
        .hard_stop_after = TICK_ETERNITY,
-       .nbproc = 1,
        .numa_cpu_mapping = 1,
        .nbthread = 0,
        .req_count = 0,
@@ -2009,19 +2008,18 @@ static void init(int argc, char **argv)
                exit(1);
        }
 
-       /* recompute the amount of per-process memory depending on nbproc and
-        * the shared SSL cache size (allowed to exist in all processes).
+       /* recompute the amount of per-process memory depending on
+        * the shared SSL cache size
         */
        if (global.rlimit_memmax_all) {
 #if defined (USE_OPENSSL) && !defined(USE_PRIVATE_CACHE)
                int64_t ssl_cache_bytes = global.tune.sslcachesize * 200LL;
 
                global.rlimit_memmax =
-                       ((((int64_t)global.rlimit_memmax_all * 1048576LL) -
-                         ssl_cache_bytes) / global.nbproc +
+                       ((((int64_t)global.rlimit_memmax_all * 1048576LL) - ssl_cache_bytes) +
                         ssl_cache_bytes + 1048575LL) / 1048576LL;
 #else
-               global.rlimit_memmax = global.rlimit_memmax_all / global.nbproc;
+               global.rlimit_memmax = global.rlimit_memmax_all;
 #endif
        }
 
@@ -2332,15 +2330,6 @@ static void init(int argc, char **argv)
                global.mode &= ~(MODE_DAEMON | MODE_QUIET);
        }
 
-       if ((global.nbproc > 1) && !(global.mode & (MODE_DAEMON | MODE_MWORKER))) {
-               if (!(global.mode & (MODE_FOREGROUND | MODE_DEBUG)))
-                       ha_warning("<nbproc> is only meaningful in daemon mode or master-worker mode. Setting limit to 1 process.\n");
-               global.nbproc = 1;
-       }
-
-       if (global.nbproc < 1)
-               global.nbproc = 1;
-
        if (global.nbthread < 1)
                global.nbthread = 1;
 
@@ -3206,7 +3195,6 @@ int main(int argc, char **argv)
 
                } else {
                        /* wait mode */
-                       global.nbproc = 1;
                        in_parent = 1;
                }
 
index 09c272c48b9c40bd139bdff110868ced3cc293ef..4c98012d24f5c7f6eb3ca3026657159c123a54f2 100644 (file)
@@ -3948,7 +3948,7 @@ static int
 smp_fetch_nbproc(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
        smp->data.type = SMP_T_SINT;
-       smp->data.u.sint = global.nbproc;
+       smp->data.u.sint = 1;
        return 1;
 }
 
index 68391326d79d96e8b78c4f1cb2fc03109ee1f69a..059fef3f42b8da043bb9d8c035e1196857defe55 100644 (file)
@@ -4979,8 +4979,7 @@ int ssl_sock_prepare_bind_conf(struct bind_conf *bind_conf)
        if (!ssl_shctx && global.tune.sslcachesize) {
                alloc_ctx = shctx_init(&ssl_shctx, global.tune.sslcachesize,
                                       sizeof(struct sh_ssl_sess_hdr) + SHSESS_BLOCK_MIN_SIZE, -1,
-                                      sizeof(*sh_ssl_sess_tree),
-                                      ((global.nbthread > 1) || (!global_ssl.private_cache && (global.nbproc > 1))) ? 1 : 0);
+                                      sizeof(*sh_ssl_sess_tree), (global.nbthread > 1));
                if (alloc_ctx <= 0) {
                        if (alloc_ctx == SHCTX_E_INIT_LOCK)
                                ha_alert("Unable to initialize the lock for the shared SSL session cache. You can retry using the global statement 'tune.ssl.force-private-cache' but it could increase CPU usage due to renegotiations if nbproc > 1.\n");
index 1f2a6849521fd6a9727edeb10d8554bb849bfe7d..1c0d45f8a7588a246b95abddc638c99533089007 100644 (file)
@@ -86,7 +86,7 @@ const struct name_desc info_fields[INF_TOTAL_FIELDS] = {
        [INF_VERSION]                        = { .name = "Version",                     .desc = "Product version" },
        [INF_RELEASE_DATE]                   = { .name = "Release_date",                .desc = "Date of latest source code update" },
        [INF_NBTHREAD]                       = { .name = "Nbthread",                    .desc = "Number of started threads (global.nbthread)" },
-       [INF_NBPROC]                         = { .name = "Nbproc",                      .desc = "Number of started worker processes (global.nbproc)" },
+       [INF_NBPROC]                         = { .name = "Nbproc",                      .desc = "Number of started worker processes (historical, always 1)" },
        [INF_PROCESS_NUM]                    = { .name = "Process_num",                 .desc = "Relative worker process number (1..Nbproc)" },
        [INF_PID]                            = { .name = "Pid",                         .desc = "This worker process identifier for the system" },
        [INF_UPTIME]                         = { .name = "Uptime",                      .desc = "How long ago this worker process was started (days+hours+minutes+seconds)" },
@@ -3339,7 +3339,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
                      (appctx->ctx.stats.flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "",
                      (appctx->ctx.stats.flags & STAT_SHDESC) ? ": " : "",
                      (appctx->ctx.stats.flags & STAT_SHDESC) ? (uri->desc ? uri->desc : global.desc) : "",
-                     pid, relative_pid, global.nbproc, global.nbthread,
+                     pid, relative_pid, 1, global.nbthread,
                      up / 86400, (up % 86400) / 3600,
                      (up % 3600) / 60, (up % 60),
                      global.rlimit_memmax ? ultoa(global.rlimit_memmax) : "unlimited",
@@ -4319,7 +4319,7 @@ int stats_fill_info(struct field *info, int len, uint flags)
        info[INF_RELEASE_DATE]                   = mkf_str(FO_PRODUCT|FN_OUTPUT|FS_SERVICE, haproxy_date);
 
        info[INF_NBTHREAD]                       = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbthread);
-       info[INF_NBPROC]                         = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbproc);
+       info[INF_NBPROC]                         = mkf_u32(FO_CONFIG|FS_SERVICE, 1);
        info[INF_PROCESS_NUM]                    = mkf_u32(FO_KEY, relative_pid);
        info[INF_PID]                            = mkf_u32(FO_STATUS, pid);