From 71e459eea31e9e47c0ce64a78e32b242d357f9a0 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 7 Dec 2024 11:44:22 -0800 Subject: fini: add drain mechanism for aio, reap, and task subsystems Make sure *everything* is drained before proceeding all the way to deallocation. --- src/core/reap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/core/reap.c') diff --git a/src/core/reap.c b/src/core/reap.c index 3f182205..f996695d 100644 --- a/src/core/reap.c +++ b/src/core/reap.c @@ -18,9 +18,9 @@ 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 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_work_cv = NNI_CV_INITIALIZER(&reap_mtx); static nni_cv reap_empty_cv = NNI_CV_INITIALIZER(&reap_mtx); static void @@ -90,14 +90,17 @@ nni_reap(nni_reap_list *rl, void *item) nni_mtx_unlock(&reap_mtx); } -void -nni_reap_drain(void) +bool +nni_reap_sys_drain(void) { + bool result = false; nni_mtx_lock(&reap_mtx); while (!reap_empty) { + result = true; nni_cv_wait(&reap_empty_cv); } nni_mtx_unlock(&reap_mtx); + return (result); } int -- cgit v1.2.3-70-g09d2