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.
This commit is contained in:
Willy Tarreau 2021-06-15 08:08:04 +02:00
parent 6185a0343b
commit 91358595f8
5 changed files with 9 additions and 23 deletions

View 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 */

View 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;
}

View 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;
}

View 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");

View 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);