From: Willy Tarreau Date: Tue, 15 Jun 2021 06:08:04 +0000 (+0200) Subject: CLEANUP: global: remove the nbproc field from the global structure X-Git-Tag: v2.5-dev1~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91358595f86202102fa788926b8b11fd0d110f12;p=thirdparty%2Fhaproxy.git CLEANUP: global: remove the nbproc field from the global structure Let's use 1 in the rare places where it was still referenced since it's now its only possible value. --- diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 057d90e618..b5ecc553aa 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -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 */ diff --git a/src/haproxy.c b/src/haproxy.c index c4f2c9be8c..26c70bdfff 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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(" 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; } diff --git a/src/sample.c b/src/sample.c index 09c272c48b..4c98012d24 100644 --- a/src/sample.c +++ b/src/sample.c @@ -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; } diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 68391326d7..059fef3f42 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -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"); diff --git a/src/stats.c b/src/stats.c index 1f2a684952..1c0d45f8a7 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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);