diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-06 07:48:28 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-06 07:48:28 -0700 |
| commit | 993373140212da702e1a845188cbe4dc44a76ad5 (patch) | |
| tree | e1719b323e8a5fd0f28185d7ba338e693fe1f551 | |
| parent | 4c3e4af7f989eae6688a7710f21241b72a3ad0b0 (diff) | |
| download | nng-993373140212da702e1a845188cbe4dc44a76ad5.tar.gz nng-993373140212da702e1a845188cbe4dc44a76ad5.tar.bz2 nng-993373140212da702e1a845188cbe4dc44a76ad5.zip | |
Make objhash fini calls idempotent.
| -rw-r--r-- | src/core/objhash.c | 3 | ||||
| -rw-r--r-- | src/core/socket.c | 11 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/core/objhash.c b/src/core/objhash.c index 9529ac30..a25b35d9 100644 --- a/src/core/objhash.c +++ b/src/core/objhash.c @@ -82,6 +82,9 @@ nni_objhash_init(nni_objhash **ohp, nni_objhash_ctor ctor, void nni_objhash_fini(nni_objhash *oh) { + if (oh == NULL) { + return; + } if (oh->oh_nodes != NULL) { nni_free(oh->oh_nodes, oh->oh_cap * sizeof (nni_objhash_node)); oh->oh_nodes = NULL; diff --git a/src/core/socket.c b/src/core/socket.c index 02a18a7a..ffacd59a 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -13,7 +13,7 @@ // Socket implementation. -static nni_objhash *nni_socks; +static nni_objhash *nni_socks = NULL; uint32_t nni_sock_id(nni_sock *s) @@ -429,6 +429,7 @@ void nni_sock_sys_fini(void) { nni_objhash_fini(nni_socks); + nni_socks = NULL; } @@ -628,14 +629,6 @@ nni_sock_close(nni_sock *sock) nni_objhash_unref(nni_socks, sock->s_id); nni_objhash_unref_wait(nni_socks, sock->s_id); - - nni_mtx_lock(nni_idlock); - // XXX: CLEAN THIS UP - if (nni_objhash_count(nni_socks) == 0) { - nni_idhash_reclaim(nni_pipes); - nni_idhash_reclaim(nni_endpoints); - } - nni_mtx_unlock(nni_idlock); } |
