From a300db42527a3eff0b037b3aa5fa3ff50f8227d4 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Jan 2025 09:09:58 -0800 Subject: reap: use sys init and fini instead of NNI_CV_INITIALIZER. The CV_INITIALIZER is error prone, as it cannot use cv_until. --- src/core/reap.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/core') 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. +// Copyright 2025 Staysail Systems, Inc. // Copyright 2017 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -14,14 +14,13 @@ #include -// 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. } -- cgit v1.2.3-70-g09d2