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.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c
index ab0d8cb9..74bd0314 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -253,7 +253,9 @@ nni_ep_connect(nni_ep *ep)
nni_pipe_remove(pipe);
return (rv);
}
+ nni_mtx_lock(&ep->ep_mtx);
ep->ep_pipe = pipe;
+ nni_mtx_unlock(&ep->ep_mtx);
return (0);
}
@@ -277,17 +279,19 @@ nni_ep_pipe_add(nni_ep *ep, nni_pipe *pipe)
void
nni_ep_pipe_remove(nni_ep *ep, nni_pipe *pipe)
{
- if ((ep != NULL) && (nni_list_active(&ep->ep_pipes, pipe))) {
- nni_mtx_lock(&ep->ep_mtx);
+ if (ep == NULL) {
+ return;
+ }
+ nni_mtx_lock(&ep->ep_mtx);
+ if (nni_list_active(&ep->ep_pipes, pipe)) {
nni_list_remove(&ep->ep_pipes, pipe);
if (ep->ep_pipe == pipe) {
ep->ep_pipe = NULL;
}
nni_cv_wake(&ep->ep_cv);
-
- nni_mtx_unlock(&ep->ep_mtx);
}
+ nni_mtx_unlock(&ep->ep_mtx);
}