nng: make nng_set_resolve_thread_max() apply on posix

Note: things will break if nng_set_resolve_thread_max() is modified at
runtime and more resolver are spawned. Not sure if this can actually
happen.
This commit is contained in:
oxmox 2023-02-04 00:00:14 +01:00
parent 6c33ce8deb
commit 980386152f

View file

@ -457,14 +457,14 @@ nni_posix_resolv_sysinit(void)
resolv_fini = false; resolv_fini = false;
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { for (int i = 0; i < nng_resolv_concurrency; i++) {
int rv = nni_thr_init(&resolv_thrs[i], resolv_worker, NULL); int rv = nni_thr_init(&resolv_thrs[i], resolv_worker, NULL);
if (rv != 0) { if (rv != 0) {
nni_posix_resolv_sysfini(); nni_posix_resolv_sysfini();
return (rv); return (rv);
} }
} }
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { for (int i = 0; i < nng_resolv_concurrency; i++) {
nni_thr_run(&resolv_thrs[i]); nni_thr_run(&resolv_thrs[i]);
} }
@ -479,7 +479,7 @@ nni_posix_resolv_sysfini(void)
nni_cv_wake(&resolv_cv); nni_cv_wake(&resolv_cv);
nni_mtx_unlock(&resolv_mtx); nni_mtx_unlock(&resolv_mtx);
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) { for (int i = 0; i < nng_resolv_concurrency; i++) {
nni_thr_fini(&resolv_thrs[i]); nni_thr_fini(&resolv_thrs[i]);
} }
nni_cv_fini(&resolv_cv); nni_cv_fini(&resolv_cv);