diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-22 17:51:37 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-22 17:51:37 -0700 |
| commit | d753c00d43e6dc642b2445e4821537a92b8b8d23 (patch) | |
| tree | 95b37ba9e55386a9c68a809f041b6344a2968efb /src/core/socket.c | |
| parent | e8309dcaa3e542e0b3c1f9d4c937314517cc27c5 (diff) | |
| download | nng-d753c00d43e6dc642b2445e4821537a92b8b8d23.tar.gz nng-d753c00d43e6dc642b2445e4821537a92b8b8d23.tar.bz2 nng-d753c00d43e6dc642b2445e4821537a92b8b8d23.zip | |
Start undoing the recursive references -- KISS.
Diffstat (limited to 'src/core/socket.c')
| -rw-r--r-- | src/core/socket.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index 2c20705a..257f7fa3 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -555,6 +555,10 @@ nni_sock_shutdown(nni_sock *sock) } else { linger = nni_clock() + sock->s_linger; } + + NNI_LIST_FOREACH (&sock->s_eps, ep) { + nni_ep_close(ep); + } nni_mtx_unlock(&sock->s_mx); @@ -586,8 +590,10 @@ nni_sock_shutdown(nni_sock *sock) // Stop all EPS. while ((ep = nni_list_first(&sock->s_eps)) != NULL) { + nni_list_remove(&sock->s_eps, ep); nni_mtx_unlock(&sock->s_mx); nni_ep_close(ep); + nni_ep_rele(ep); nni_mtx_lock(&sock->s_mx); } @@ -625,12 +631,9 @@ nni_sock_add_ep(nni_sock *sock, nni_ep *ep) { int rv; - nni_sock_hold(sock); - nni_mtx_lock(&sock->s_mx); if (sock->s_closing) { nni_mtx_unlock(&sock->s_mx); - nni_sock_rele(sock); return (NNG_ECLOSED); } nni_list_append(&sock->s_eps, ep); @@ -652,9 +655,6 @@ nni_sock_rem_ep(nni_sock *sock, nni_ep *ep) nni_mtx_lock(&sock->s_mx); nni_list_remove(&sock->s_eps, ep); nni_mtx_unlock(&sock->s_mx); - - // Drop the reference the EP acquired in add_ep. - nni_sock_rele(sock); } @@ -833,6 +833,7 @@ nni_sock_dial(nni_sock *sock, const char *addr, nni_ep **epp, int flags) if ((rv = nni_ep_dial(ep, flags)) != 0) { nni_ep_close(ep); + nni_ep_rele(ep); } else if (epp != NULL) { *epp = ep; } @@ -853,6 +854,7 @@ nni_sock_listen(nni_sock *sock, const char *addr, nni_ep **epp, int flags) if ((rv = nni_ep_listen(ep, flags)) != 0) { nni_ep_close(ep); + nni_ep_rele(ep); } else if (epp != NULL) { *epp = ep; } |
