aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-05 09:09:58 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-05 09:40:04 -0800
commita300db42527a3eff0b037b3aa5fa3ff50f8227d4 (patch)
tree5d7f91b76693b1ce292a6448df91b7cf7f44d79d /src/core
parent50ec02d5320d3cde101ad46844f3bec7304eda35 (diff)
downloadnng-a300db42527a3eff0b037b3aa5fa3ff50f8227d4.tar.gz
nng-a300db42527a3eff0b037b3aa5fa3ff50f8227d4.tar.bz2
nng-a300db42527a3eff0b037b3aa5fa3ff50f8227d4.zip
reap: use sys init and fini instead of NNI_CV_INITIALIZER.
The CV_INITIALIZER is error prone, as it cannot use cv_until.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/reap.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/core/reap.c b/src/core/reap.c
index 3044a041..61c6bdb9 100644
--- a/src/core/reap.c
+++ b/src/core/reap.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -14,14 +14,13 @@
#include <stdbool.h>
-// New stuff.
static nni_reap_list *reap_list = NULL;
static nni_thr reap_thr;
static bool reap_exit = false;
-static nni_mtx reap_mtx = NNI_MTX_INITIALIZER;
static bool reap_empty;
-static nni_cv reap_work_cv = NNI_CV_INITIALIZER(&reap_mtx);
-static nni_cv reap_empty_cv = NNI_CV_INITIALIZER(&reap_mtx);
+static nni_mtx reap_mtx;
+static nni_cv reap_work_cv;
+static nni_cv reap_empty_cv;
static void
reap_worker(void *unused)
@@ -109,6 +108,9 @@ nni_reap_sys_init(void)
int rv;
reap_exit = false;
+ nni_mtx_init(&reap_mtx);
+ nni_cv_init(&reap_work_cv, &reap_mtx);
+ nni_cv_init(&reap_empty_cv, &reap_mtx);
// If this fails, we don't fail init, instead we will try to
// start up at reap time.
if ((rv = nni_thr_init(&reap_thr, reap_worker, NULL)) != 0) {
@@ -127,6 +129,10 @@ nni_reap_sys_fini(void)
nni_mtx_unlock(&reap_mtx);
nni_thr_fini(&reap_thr);
+ nni_cv_fini(&reap_work_cv);
+ nni_cv_fini(&reap_empty_cv);
+ nni_mtx_fini(&reap_mtx);
+
// NB: The subsystem linkages remain in place. We don't need
// to reinitialize them across future initializations.
}