aboutsummaryrefslogtreecommitdiff
path: root/src/core/init.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-07 11:44:22 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-07 11:56:22 -0800
commit71e459eea31e9e47c0ce64a78e32b242d357f9a0 (patch)
treec4f6608066aaa6505a5625f399c94845abe6c162 /src/core/init.c
parent8fa3b2aa8e9191669f137be39ba61ad39243483a (diff)
downloadnng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.tar.gz
nng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.tar.bz2
nng-71e459eea31e9e47c0ce64a78e32b242d357f9a0.zip
fini: add drain mechanism for aio, reap, and task subsystems
Make sure *everything* is drained before proceeding all the way to deallocation.
Diffstat (limited to 'src/core/init.c')
-rw-r--r--src/core/init.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/init.c b/src/core/init.c
index fa07919e..4b31995a 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -133,13 +133,18 @@ nng_fini(void)
nni_atomic_flag_reset(&init_busy);
return;
}
- nni_aio_sys_stop(); // no more scheduling allowed!
nni_sock_closeall();
nni_sp_tran_sys_fini();
+
+ // Drain everything. This is important because some of
+ // these subsystems can dispatch things to other ones.
+ // So we need them *all* to be empty before proceeding.
+ while ((nni_aio_sys_drain() || nni_taskq_sys_drain() ||
+ nni_reap_sys_drain())) {
+ continue;
+ }
nni_tls_sys_fini();
- nni_reap_drain();
nni_taskq_sys_fini();
- nni_reap_drain();
nni_aio_sys_fini();
nni_id_map_sys_fini();
nni_reap_sys_fini(); // must be near the end