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/reap.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/reap.h') diff --git a/src/core/reap.h b/src/core/reap.h index 843c8c9c..40c27a5d 100644 --- a/src/core/reap.h +++ b/src/core/reap.h @@ -38,6 +38,7 @@ typedef struct nni_reap_item { // part of a fully reapable graph; otherwise this can lead to an infinite // loop in the reap thread. extern void nni_reap(nni_reap_item *, nni_cb, void *); +extern void nni_reap_drain(void); extern int nni_reap_sys_init(void); extern void nni_reap_sys_fini(void); -- cgit v1.2.3-70-g09d2