From 15869e302e4f15c4c46bf5dc4bdf2aea96f513e0 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 24 Feb 2020 05:57:35 -0800 Subject: fixes #1202 More than 120 threads was started by NNG This introduces a new CMake option, NNG_MAX_TASKQ_THREADS, with a default value of 16. The number of taskq workers will generally be calculated as vcpu * 2. This new value, if not zero, sets an upper bound. Note that the value should be at least two, in order to ensure no deadlocks occur. --- src/core/taskq.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/taskq.c') diff --git a/src/core/taskq.c b/src/core/taskq.c index 09e822df..e63e33c7 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -228,6 +228,11 @@ nni_taskq_sys_init(void) #else nthrs = NNG_NUM_TASKQ_THREADS; #endif +#if NNG_MAX_TASKQ_THREADS > 0 + if (nthrs > NNG_MAX_TASKQ_THREADS) { + nthrs = NNG_MAX_TASKQ_THREADS; + } +#endif return (nni_taskq_init(&nni_taskq_systq, nthrs)); } -- cgit v1.2.3-70-g09d2