From b19e1bfb8305450ec04077dcae539c7049824796 Mon Sep 17 00:00:00 2001 From: Matt Gigli Date: Sun, 9 Dec 2018 15:28:10 -0800 Subject: fixes #769 How to limit worker threads * Expose cmake variable to set number of DNS resolver threads: NNG_RESOLV_CONCURRENCY * Expose cmake variable to set number of taskq threads: NNG_NUM_TASKQ_THREADS --- src/platform/windows/win_resolv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/platform/windows') diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c index aca07ecb..d361a1e8 100644 --- a/src/platform/windows/win_resolv.c +++ b/src/platform/windows/win_resolv.c @@ -22,15 +22,15 @@ // host file, WINS, or other naming services. As a result, we just build // our own limited asynchronous resolver with threads. -#ifndef NNG_WIN_RESOLV_CONCURRENCY -#define NNG_WIN_RESOLV_CONCURRENCY 4 +#ifndef NNG_RESOLV_CONCURRENCY +#define NNG_RESOLV_CONCURRENCY 4 #endif static nni_mtx resolv_mtx; static nni_cv resolv_cv; static bool resolv_fini; static nni_list resolv_aios; -static nni_thr resolv_thrs[NNG_WIN_RESOLV_CONCURRENCY]; +static nni_thr resolv_thrs[NNG_RESOLV_CONCURRENCY]; typedef struct resolv_item resolv_item; struct resolv_item { @@ -355,14 +355,14 @@ nni_win_resolv_sysinit(void) nni_aio_list_init(&resolv_aios); resolv_fini = false; - for (int i = 0; i < NNG_WIN_RESOLV_CONCURRENCY; i++) { + for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { int rv = nni_thr_init(&resolv_thrs[i], resolv_worker, NULL); if (rv != 0) { nni_win_resolv_sysfini(); return (rv); } } - for (int i = 0; i < NNG_WIN_RESOLV_CONCURRENCY; i++) { + for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { nni_thr_run(&resolv_thrs[i]); } return (0); @@ -375,7 +375,7 @@ nni_win_resolv_sysfini(void) resolv_fini = true; nni_cv_wake(&resolv_cv); nni_mtx_unlock(&resolv_mtx); - for (int i = 0; i < NNG_WIN_RESOLV_CONCURRENCY; i++) { + for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { nni_thr_fini(&resolv_thrs[i]); } nni_cv_fini(&resolv_cv); -- cgit v1.2.3-70-g09d2