From 953ca274ae57f8edd12536a3dd15d134aa6e5576 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 6 Jul 2018 14:42:53 -0700 Subject: fixes #568 Want a single reader/write lock on socket child objects fixes #170 Make more use of reaper This is a complete restructure/rethink of how child objects interact with the socket. (This also backs out #576 as it turns out not to be needed.) While 568 says reader/writer lock, for now we have settled for a single writer lock. Its likely that this is sufficient. Essentially we use the single socket lock to guard lists of the socket children. We also use deferred deletion in the idhash to facilitate teardown, which means endpoint closes are no longer synchronous. We use the reaper to clean up objects when the reference count drops to zero. We make a special exception for pipes, since they really are not reference counted by their parents, and they are leaf objects anyway. We believe this addresses the main outstanding race conditions in a much more correct and holistic way. Note that endpoint shutdown is a little tricky, as it makes use of atomic flags to guard against double entry, and against recursive lock entry. This is something that would be nice to make a bit more obvious, but what we have is safe, and the complexity is at least confined to one place. --- src/core/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/init.c') diff --git a/src/core/init.c b/src/core/init.c index 30a7a547..c66e54d2 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -75,11 +75,12 @@ nni_fini(void) nni_dialer_sys_fini(); nni_listener_sys_fini(); nni_sock_sys_fini(); - nni_reap_sys_fini(); // must be before timer and aio (expire) + nni_reap_drain(); nni_random_sys_fini(); nni_aio_sys_fini(); nni_timer_sys_fini(); nni_taskq_sys_fini(); + nni_reap_sys_fini(); // must be before timer and aio (expire) nni_mtx_fini(&nni_init_mtx); nni_plat_fini(); -- cgit v1.2.3-70-g09d2