From 763b8deee1fd38566b85d4745a83adae245d9b26 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 21 Jun 2017 14:04:16 -0700 Subject: Make APIs for holding references more consistent. --- src/core/endpt.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/core/endpt.c') diff --git a/src/core/endpt.c b/src/core/endpt.c index 91ddb318..326bac48 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -39,7 +39,7 @@ nni_ep_sys_fini(void) int -nni_ep_hold(nni_ep **epp, uint32_t id) +nni_ep_find(nni_ep **epp, uint32_t id) { int rv; nni_ep *ep; @@ -66,6 +66,16 @@ nni_ep_hold(nni_ep **epp, uint32_t id) } +void +nni_ep_hold(nni_ep *ep) +{ + int rv; + + rv = nni_objhash_find(nni_eps, ep->ep_id, NULL); + NNI_ASSERT(rv == 0); +} + + void nni_ep_rele(nni_ep *ep) { @@ -226,11 +236,7 @@ nni_ep_connect(nni_ep *ep, nni_pipe **pp) int nni_ep_add_pipe(nni_ep *ep, nni_pipe *pipe) { - int rv; - - if ((rv = nni_ep_hold(NULL, ep->ep_id)) != 0) { - return (rv); - } + nni_ep_hold(ep); nni_mtx_lock(&ep->ep_mtx); if (ep->ep_close) { nni_mtx_unlock(&ep->ep_mtx); -- cgit v1.2.3-70-g09d2