aboutsummaryrefslogtreecommitdiff
path: root/src/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/windows')
-rw-r--r--src/platform/windows/win_impl.h2
-rw-r--r--src/platform/windows/win_resolv.c14
2 files changed, 7 insertions, 9 deletions
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h
index b3c08edf..bbd007d0 100644
--- a/src/platform/windows/win_impl.h
+++ b/src/platform/windows/win_impl.h
@@ -53,6 +53,8 @@ struct nni_plat_cv {
PSRWLOCK srl;
};
+#define NNI_CV_INITIALIZER(mxp) { .srl = mxp, .cv = CONDITION_VARIABLE_INIT }
+
struct nni_atomic_flag {
unsigned f;
};
diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c
index 8628719f..f855e255 100644
--- a/src/platform/windows/win_resolv.c
+++ b/src/platform/windows/win_resolv.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -26,9 +26,9 @@
#define NNG_RESOLV_CONCURRENCY 4
#endif
-static nni_mtx resolv_mtx;
-static nni_cv resolv_cv;
-static bool resolv_fini;
+static nni_mtx resolv_mtx = NNI_MTX_INITIALIZER;
+static nni_cv resolv_cv = NNI_CV_INITIALIZER(&resolv_mtx);
+static bool resolv_fini = false;
static nni_list resolv_aios;
static nni_thr resolv_thrs[NNG_RESOLV_CONCURRENCY];
@@ -408,11 +408,9 @@ nni_parse_ip_port(const char *addr, nni_sockaddr *sa)
int
nni_win_resolv_sysinit(void)
{
- nni_mtx_init(&resolv_mtx);
- nni_cv_init(&resolv_cv, &resolv_mtx);
nni_aio_list_init(&resolv_aios);
-
resolv_fini = false;
+
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) {
int rv = nni_thr_init(&resolv_thrs[i], resolv_worker, NULL);
if (rv != 0) {
@@ -437,8 +435,6 @@ nni_win_resolv_sysfini(void)
for (int i = 0; i < NNG_RESOLV_CONCURRENCY; i++) {
nni_thr_fini(&resolv_thrs[i]);
}
- nni_cv_fini(&resolv_cv);
- nni_mtx_fini(&resolv_mtx);
}
#endif // NNG_PLATFORM_WINDOWS