aboutsummaryrefslogtreecommitdiff
path: root/src/core/endpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/endpt.c')
-rw-r--r--src/core/endpt.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c
index 362af82c..92a974a8 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -166,6 +166,13 @@ nni_ep_close(nni_ep *ep)
nni_mtx *mx = &ep->ep_sock->s_mx;
nni_mtx_lock(nni_idlock);
+ if (ep->ep_id != 0) {
+ // We might have removed this already as a result of
+ // application initiated endpoint close request instead
+ // of socket close.
+ nni_idhash_remove(nni_endpoints, ep->ep_id);
+ ep->ep_id = 0;
+ }
while (ep->ep_refcnt) {
nni_cv_wait(&ep->ep_refcv);
}
@@ -186,15 +193,6 @@ nni_ep_close(nni_ep *ep)
nni_thr_fini(&ep->ep_thr);
ep->ep_ops.ep_fini(ep->ep_data);
- nni_mtx_lock(nni_idlock);
- if (ep->ep_id != 0) {
- // We might have removed this already as a result of
- // application initiated endpoint close request instead
- // of socket close.
- nni_idhash_remove(nni_endpoints, ep->ep_id);
- }
- nni_mtx_unlock(nni_idlock);
-
nni_cv_fini(&ep->ep_cv);
NNI_FREE_STRUCT(ep);
}
@@ -498,3 +496,10 @@ nni_ep_listen(nni_ep *ep, int flags)
return (0);
}
+
+
+void
+nni_ep_list_init(nni_list *list)
+{
+ NNI_LIST_INIT(list, nni_ep, ep_node);
+}