diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-21 14:04:16 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-21 14:04:16 -0700 |
| commit | 763b8deee1fd38566b85d4745a83adae245d9b26 (patch) | |
| tree | 00404dbc8e6c07fc5a9d8e07f353beff3adefd5a | |
| parent | f81c7e8cc84bd43bfc3cc5e41f773a0078870312 (diff) | |
| download | nng-763b8deee1fd38566b85d4745a83adae245d9b26.tar.gz nng-763b8deee1fd38566b85d4745a83adae245d9b26.tar.bz2 nng-763b8deee1fd38566b85d4745a83adae245d9b26.zip | |
Make APIs for holding references more consistent.
| -rw-r--r-- | src/core/endpt.c | 18 | ||||
| -rw-r--r-- | src/core/endpt.h | 3 | ||||
| -rw-r--r-- | src/core/objhash.c | 4 | ||||
| -rw-r--r-- | src/core/pipe.c | 8 | ||||
| -rw-r--r-- | src/core/pipe.h | 4 | ||||
| -rw-r--r-- | src/core/socket.c | 17 | ||||
| -rw-r--r-- | src/core/socket.h | 3 | ||||
| -rw-r--r-- | src/nng.c | 30 | ||||
| -rw-r--r-- | src/protocol/bus/bus.c | 14 | ||||
| -rw-r--r-- | src/protocol/pair/pair.c | 12 | ||||
| -rw-r--r-- | src/protocol/pipeline/pull.c | 8 | ||||
| -rw-r--r-- | src/protocol/pipeline/push.c | 10 | ||||
| -rw-r--r-- | src/protocol/pubsub/pub.c | 10 | ||||
| -rw-r--r-- | src/protocol/pubsub/sub.c | 6 | ||||
| -rw-r--r-- | src/protocol/reqrep/rep.c | 14 | ||||
| -rw-r--r-- | src/protocol/reqrep/req.c | 16 | ||||
| -rw-r--r-- | src/protocol/survey/respond.c | 12 | ||||
| -rw-r--r-- | src/protocol/survey/survey.c | 12 |
18 files changed, 109 insertions, 92 deletions
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; @@ -67,6 +67,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) { nni_objhash_unref(nni_eps, ep->ep_id); @@ -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); diff --git a/src/core/endpt.h b/src/core/endpt.h index 7991a916..2f2a5067 100644 --- a/src/core/endpt.h +++ b/src/core/endpt.h @@ -42,7 +42,8 @@ struct nni_ep { extern int nni_ep_sys_init(void); extern void nni_ep_sys_fini(void); -extern int nni_ep_hold(nni_ep **, uint32_t); +extern int nni_ep_find(nni_ep **, uint32_t); +extern void nni_ep_hold(nni_ep *); extern void nni_ep_rele(nni_ep *); extern uint32_t nni_ep_id(nni_ep *); extern int nni_ep_create(nni_ep **, nni_sock *, const char *); diff --git a/src/core/objhash.c b/src/core/objhash.c index 94c42dcf..5ee5f5c7 100644 --- a/src/core/objhash.c +++ b/src/core/objhash.c @@ -145,7 +145,9 @@ nni_objhash_find(nni_objhash *oh, uint32_t id, void **valp) node = nni_objhash_find_node(oh, id); if ((node != NULL) && (node->on_val != NULL)) { - *valp = node->on_val; + if (valp != NULL) { + *valp = node->on_val; + } node->on_refcnt++; rv = 0; } else { diff --git a/src/core/pipe.c b/src/core/pipe.c index 58703814..80b39171 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -102,19 +102,17 @@ nni_pipe_aio_send(nni_pipe *p, nni_aio *aio) void -nni_pipe_incref(nni_pipe *p) +nni_pipe_hold(nni_pipe *p) { int rv; - nni_pipe *scratch; - rv = nni_objhash_find(nni_pipes, p->p_id, (void **) &scratch); + rv = nni_objhash_find(nni_pipes, p->p_id, NULL); NNI_ASSERT(rv == 0); - NNI_ASSERT(p == scratch); } void -nni_pipe_decref(nni_pipe *p) +nni_pipe_rele(nni_pipe *p) { nni_objhash_unref(nni_pipes, p->p_id); } diff --git a/src/core/pipe.h b/src/core/pipe.h index e9ce89b3..379b1d8a 100644 --- a/src/core/pipe.h +++ b/src/core/pipe.h @@ -42,8 +42,8 @@ extern int nni_pipe_aio_send(nni_pipe *, nni_aio *); // Pipe operations that protocols use. extern uint32_t nni_pipe_id(nni_pipe *); extern void nni_pipe_close(nni_pipe *); -extern void nni_pipe_incref(nni_pipe *); -extern void nni_pipe_decref(nni_pipe *); +extern void nni_pipe_hold(nni_pipe *); +extern void nni_pipe_rele(nni_pipe *); // Used only by the socket core - as we don't wish to expose the details // of the pipe structure outside of pipe.c. diff --git a/src/core/socket.c b/src/core/socket.c index ee653780..195bbcf3 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -39,7 +39,7 @@ nni_sock_recvq(nni_sock *s) int -nni_sock_hold(nni_sock **sockp, uint32_t id) +nni_sock_find(nni_sock **sockp, uint32_t id) { int rv; nni_sock *sock; @@ -66,6 +66,16 @@ nni_sock_hold(nni_sock **sockp, uint32_t id) void +nni_sock_hold(nni_sock *sock) +{ + int rv; + + rv = nni_objhash_find(nni_socks, sock->s_id, NULL); + NNI_ASSERT(rv == 0); +} + + +void nni_sock_rele(nni_sock *sock) { nni_objhash_unref(nni_socks, sock->s_id); @@ -615,9 +625,8 @@ nni_sock_add_ep(nni_sock *sock, nni_ep *ep) { int rv; - if ((rv = nni_sock_hold(NULL, sock->s_id)) != 0) { - return (rv); - } + nni_sock_hold(sock); + nni_mtx_lock(&sock->s_mx); if (sock->s_closing) { nni_mtx_unlock(&sock->s_mx); diff --git a/src/core/socket.h b/src/core/socket.h index 15183f6b..68f05705 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -63,7 +63,8 @@ struct nni_socket { extern int nni_sock_sys_init(void); extern void nni_sock_sys_fini(void); -extern int nni_sock_hold(nni_sock **, uint32_t); +extern int nni_sock_find(nni_sock **, uint32_t); +extern void nni_sock_hold(nni_sock *); extern void nni_sock_rele(nni_sock *); extern int nni_sock_open(nni_sock **, uint16_t); extern void nni_sock_close(nni_sock *); @@ -43,7 +43,7 @@ nng_shutdown(nng_socket sid) int rv; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } rv = nni_sock_shutdown(sock); @@ -60,7 +60,7 @@ nng_close(nng_socket sid) // Close is special, because we still want to be able to get // a hold on the socket even if shutdown was called. - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } // No release -- close releases it. @@ -76,7 +76,7 @@ nng_protocol(nng_socket sid) uint16_t pnum; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } pnum = nni_sock_proto(sock); @@ -92,7 +92,7 @@ nng_peer(nng_socket sid) uint16_t pnum; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } pnum = nni_sock_peer(sock); @@ -145,7 +145,7 @@ nng_recvmsg(nng_socket sid, nng_msg **msgp, int flags) int rv; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } if ((flags == NNG_FLAG_NONBLOCK) || (sock->s_rcvtimeo == 0)) { @@ -203,7 +203,7 @@ nng_sendmsg(nng_socket sid, nng_msg *msg, int flags) int rv; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } if ((flags == NNG_FLAG_NONBLOCK) || (sock->s_sndtimeo == 0)) { @@ -228,7 +228,7 @@ nng_dial(nng_socket sid, const char *addr, nng_endpoint *epp, int flags) int rv; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } if ((rv = nni_sock_dial(sock, addr, &ep, flags)) == 0) { @@ -248,7 +248,7 @@ nng_listen(nng_socket sid, const char *addr, nng_endpoint *epp, int flags) int rv; nni_sock *sock; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } if ((rv = nni_sock_listen(sock, addr, &ep, flags)) == 0) { @@ -267,7 +267,7 @@ nng_endpoint_close(nng_endpoint eid) int rv; nni_ep *ep; - if ((rv = nni_ep_hold(&ep, eid)) != 0) { + if ((rv = nni_ep_find(&ep, eid)) != 0) { return (rv); } nni_ep_close(ep); @@ -281,7 +281,7 @@ nng_setopt(nng_socket sid, int opt, const void *val, size_t sz) nni_sock *sock; int rv; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } rv = nni_sock_setopt(sock, opt, val, sz); @@ -296,7 +296,7 @@ nng_getopt(nng_socket sid, int opt, void *val, size_t *szp) nni_sock *sock; int rv; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } rv = nni_sock_getopt(sock, opt, val, szp); @@ -312,7 +312,7 @@ nng_setnotify(nng_socket sid, int mask, nng_notify_func fn, void *arg) nng_notify *notify; int rv; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return (NULL); } notify = nni_sock_notify(sock, mask, fn, arg); @@ -327,7 +327,7 @@ nng_unsetnotify(nng_socket sid, nng_notify *notify) nni_sock *sock; int rv; - if ((rv = nni_sock_hold(&sock, sid)) != 0) { + if ((rv = nni_sock_find(&sock, sid)) != 0) { return; } nni_sock_unnotify(sock, notify); @@ -358,12 +358,12 @@ nng_device(nng_socket s1, nng_socket s2) nni_sock *sock2 = NULL; if ((s1 > 0) && (s1 != (nng_socket)-1)) { - if ((rv = nni_sock_hold(&sock1, s1)) != 0) { + if ((rv = nni_sock_find(&sock1, s1)) != 0) { return (rv); } } if (((s2 > 0) && (s2 != (nng_socket)-1)) && (s2 != s1)) { - if ((rv = nni_sock_hold(&sock2, s2)) != 0) { + if ((rv = nni_sock_find(&sock2, s2)) != 0) { nni_sock_rele(sock1); return (rv); } diff --git a/src/protocol/bus/bus.c b/src/protocol/bus/bus.c index e8428e42..ca24c32c 100644 --- a/src/protocol/bus/bus.c +++ b/src/protocol/bus/bus.c @@ -172,9 +172,9 @@ nni_bus_pipe_start(void *arg) nni_list_append(&psock->pipes, ppipe); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_bus_pipe_recv(ppipe); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_bus_pipe_getq(ppipe); return (0); @@ -205,7 +205,7 @@ nni_bus_pipe_getq_cb(void *arg) if (nni_aio_result(&ppipe->aio_getq) != 0) { // closed? nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } ppipe->aio_send.a_msg = ppipe->aio_getq.a_msg; @@ -225,7 +225,7 @@ nni_bus_pipe_send_cb(void *arg) nni_msg_free(ppipe->aio_send.a_msg); ppipe->aio_send.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -243,7 +243,7 @@ nni_bus_pipe_recv_cb(void *arg) if (nni_aio_result(&ppipe->aio_recv) != 0) { nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } msg = ppipe->aio_recv.a_msg; @@ -253,7 +253,7 @@ nni_bus_pipe_recv_cb(void *arg) // XXX: bump a nomemory stat nni_msg_free(msg); nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -271,7 +271,7 @@ nni_bus_pipe_putq_cb(void *arg) nni_msg_free(ppipe->aio_putq.a_msg); ppipe->aio_putq.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } diff --git a/src/protocol/pair/pair.c b/src/protocol/pair/pair.c index ed5cee9f..a2b97fe0 100644 --- a/src/protocol/pair/pair.c +++ b/src/protocol/pair/pair.c @@ -142,9 +142,9 @@ nni_pair_pipe_start(void *arg) // Schedule a getq on the upper, and a read from the pipe. // Each of these also sets up another hold on the pipe itself. - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_msgq_aio_get(psock->uwq, &ppipe->aio_getq); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); return (0); @@ -174,7 +174,7 @@ nni_pair_recv_cb(void *arg) if (nni_aio_result(&ppipe->aio_recv) != 0) { nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -193,7 +193,7 @@ nni_pair_putq_cb(void *arg) nni_msg_free(ppipe->aio_putq.a_msg); ppipe->aio_putq.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); @@ -209,7 +209,7 @@ nni_pair_getq_cb(void *arg) if (nni_aio_result(&ppipe->aio_getq) != 0) { nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -229,7 +229,7 @@ nni_pair_send_cb(void *arg) nni_msg_free(ppipe->aio_send.a_msg); ppipe->aio_send.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } diff --git a/src/protocol/pipeline/pull.c b/src/protocol/pipeline/pull.c index b569253d..eb14be81 100644 --- a/src/protocol/pipeline/pull.c +++ b/src/protocol/pipeline/pull.c @@ -107,7 +107,7 @@ nni_pull_pipe_start(void *arg) nni_pull_pipe *pp = arg; // Start the pending pull... - nni_pipe_incref(pp->pipe); + nni_pipe_hold(pp->pipe); nni_pull_recv(pp); return (0); @@ -134,7 +134,7 @@ nni_pull_recv_cb(void *arg) if (nni_aio_result(aio) != 0) { // Failed to get a message, probably the pipe is closed. nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } @@ -158,7 +158,7 @@ nni_pull_putq_cb(void *arg) nni_msg_free(aio->a_msg); aio->a_msg = NULL; nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } @@ -173,7 +173,7 @@ nni_pull_recv(nni_pull_pipe *pp) // Schedule the aio with callback. if (nni_pipe_aio_recv(pp->pipe, &pp->recv_aio) != 0) { nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); } } diff --git a/src/protocol/pipeline/push.c b/src/protocol/pipeline/push.c index 9691d8d8..9554b2be 100644 --- a/src/protocol/pipeline/push.c +++ b/src/protocol/pipeline/push.c @@ -127,11 +127,11 @@ nni_push_pipe_start(void *arg) // Schedule a receiver. This is mostly so that we can detect // a closed transport pipe. - nni_pipe_incref(pp->pipe); + nni_pipe_hold(pp->pipe); nni_pipe_aio_recv(pp->pipe, &pp->aio_recv); // Schedule a sender. - nni_pipe_incref(pp->pipe); + nni_pipe_hold(pp->pipe); nni_msgq_aio_get(push->uwq, &pp->aio_getq); return (0); @@ -157,7 +157,7 @@ nni_push_recv_cb(void *arg) // sends us data, we just discard it. if (nni_aio_result(&pp->aio_recv) != 0) { nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } nni_msg_free(pp->aio_recv.a_msg); @@ -176,7 +176,7 @@ nni_push_send_cb(void *arg) nni_msg_free(pp->aio_send.a_msg); pp->aio_send.a_msg = NULL; nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } @@ -193,7 +193,7 @@ nni_push_getq_cb(void *arg) if (nni_aio_result(aio) != 0) { // If the socket is closing, nothing else we can do. nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } diff --git a/src/protocol/pubsub/pub.c b/src/protocol/pubsub/pub.c index 8ca7f0f9..5ea16d2d 100644 --- a/src/protocol/pubsub/pub.c +++ b/src/protocol/pubsub/pub.c @@ -156,9 +156,9 @@ nni_pub_pipe_start(void *arg) nni_list_append(&pub->pipes, pp); // Start the receiver and the queue reader. - nni_pipe_incref(pp->pipe); + nni_pipe_hold(pp->pipe); nni_pipe_aio_recv(pp->pipe, &pp->aio_recv); - nni_pipe_incref(pp->pipe); + nni_pipe_hold(pp->pipe); nni_msgq_aio_get(pp->sendq, &pp->aio_getq); return (0); @@ -229,7 +229,7 @@ nni_pub_pipe_recv_cb(void *arg) if (nni_aio_result(&pp->aio_recv) != 0) { nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } @@ -246,7 +246,7 @@ nni_pub_pipe_getq_cb(void *arg) if (nni_aio_result(&pp->aio_getq) != 0) { nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } @@ -266,7 +266,7 @@ nni_pub_pipe_send_cb(void *arg) nni_msg_free(pp->aio_send.a_msg); pp->aio_send.a_msg = NULL; nni_pipe_close(pp->pipe); - nni_pipe_decref(pp->pipe); + nni_pipe_rele(pp->pipe); return; } diff --git a/src/protocol/pubsub/sub.c b/src/protocol/pubsub/sub.c index 7b6e908e..8340da77 100644 --- a/src/protocol/pubsub/sub.c +++ b/src/protocol/pubsub/sub.c @@ -117,7 +117,7 @@ nni_sub_pipe_start(void *arg) { nni_sub_pipe *sp = arg; - nni_pipe_incref(sp->pipe); + nni_pipe_hold(sp->pipe); nni_pipe_aio_recv(sp->pipe, &sp->aio_recv); return (0); } @@ -142,7 +142,7 @@ nni_sub_recv_cb(void *arg) if (nni_aio_result(&sp->aio_recv) != 0) { nni_pipe_close(sp->pipe); - nni_pipe_decref(sp->pipe); + nni_pipe_rele(sp->pipe); return; } @@ -161,7 +161,7 @@ nni_sub_putq_cb(void *arg) nni_msg_free(sp->aio_putq.a_msg); sp->aio_putq.a_msg = NULL; nni_pipe_close(sp->pipe); - nni_pipe_decref(sp->pipe); + nni_pipe_rele(sp->pipe); return; } diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c index 5a5f6bff..822758ef 100644 --- a/src/protocol/reqrep/rep.c +++ b/src/protocol/reqrep/rep.c @@ -182,9 +182,9 @@ nni_rep_pipe_start(void *arg) return (rv); } - nni_pipe_incref(rp->pipe); + nni_pipe_hold(rp->pipe); nni_msgq_aio_get(rp->sendq, &rp->aio_getq); - nni_pipe_incref(rp->pipe); + nni_pipe_hold(rp->pipe); nni_pipe_aio_recv(rp->pipe, &rp->aio_recv); rp->running = 1; return (0); @@ -268,7 +268,7 @@ nni_rep_pipe_getq_cb(void *arg) if (nni_aio_result(&rp->aio_getq) != 0) { nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -288,7 +288,7 @@ nni_rep_pipe_send_cb(void *arg) nni_msg_free(rp->aio_send.a_msg); rp->aio_send.a_msg = NULL; nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -309,7 +309,7 @@ nni_rep_pipe_recv_cb(void *arg) if (nni_aio_result(&rp->aio_recv) != 0) { nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -359,7 +359,7 @@ malformed: // Failures here are bad enough to warrant to dropping the conn. nni_msg_free(msg); nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); } @@ -372,7 +372,7 @@ nni_rep_pipe_putq_cb(void *arg) nni_msg_free(rp->aio_putq.a_msg); rp->aio_putq.a_msg = NULL; nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c index af4dbd42..8268ecd6 100644 --- a/src/protocol/reqrep/req.c +++ b/src/protocol/reqrep/req.c @@ -187,9 +187,9 @@ nni_req_pipe_start(void *arg) nni_req_resend(req); } - nni_pipe_incref(rp->pipe); + nni_pipe_hold(rp->pipe); nni_msgq_aio_get(req->uwq, &rp->aio_getq); - nni_pipe_incref(rp->pipe); + nni_pipe_hold(rp->pipe); nni_pipe_aio_recv(rp->pipe, &rp->aio_recv); rp->running = 1; return (0); @@ -294,7 +294,7 @@ nni_req_getq_cb(void *arg) if (nni_aio_result(&rp->aio_getq) != 0) { nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -316,7 +316,7 @@ nni_req_sendraw_cb(void *arg) nni_msg_free(rp->aio_sendraw.a_msg); rp->aio_sendraw.a_msg = NULL; nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -339,7 +339,7 @@ nni_req_sendcooked_cb(void *arg) nni_msg_free(rp->aio_sendcooked.a_msg); rp->aio_sendcooked.a_msg = NULL; nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -364,7 +364,7 @@ nni_req_putq_cb(void *arg) if (nni_aio_result(&rp->aio_putq) != 0) { nni_msg_free(rp->aio_putq.a_msg); nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } rp->aio_putq.a_msg = NULL; @@ -381,7 +381,7 @@ nni_req_recv_cb(void *arg) if (nni_aio_result(&rp->aio_recv) != 0) { nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); return; } @@ -412,7 +412,7 @@ nni_req_recv_cb(void *arg) malformed: nni_msg_free(msg); nni_pipe_close(rp->pipe); - nni_pipe_decref(rp->pipe); + nni_pipe_rele(rp->pipe); } diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c index 3b8c5bd8..71220678 100644 --- a/src/protocol/survey/respond.c +++ b/src/protocol/survey/respond.c @@ -187,10 +187,10 @@ nni_resp_pipe_start(void *arg) return (rv); } - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_msgq_aio_get(ppipe->sendq, &ppipe->aio_getq); ppipe->running = 1; return (rv); @@ -269,7 +269,7 @@ nni_resp_getq_cb(void *arg) if (nni_aio_result(&ppipe->aio_getq) != 0) { nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -289,7 +289,7 @@ nni_resp_send_cb(void *arg) nni_msg_free(ppipe->aio_send.a_msg); ppipe->aio_send.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -359,7 +359,7 @@ nni_resp_recv_cb(void *arg) error: nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); } @@ -372,7 +372,7 @@ nni_resp_putq_cb(void *arg) nni_msg_free(ppipe->aio_putq.a_msg); ppipe->aio_putq.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); } nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); diff --git a/src/protocol/survey/survey.c b/src/protocol/survey/survey.c index 0edcfef2..f72532de 100644 --- a/src/protocol/survey/survey.c +++ b/src/protocol/survey/survey.c @@ -176,10 +176,10 @@ nni_surv_pipe_start(void *arg) nni_list_append(&psock->pipes, ppipe); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_msgq_aio_get(ppipe->sendq, &ppipe->aio_getq); - nni_pipe_incref(ppipe->npipe); + nni_pipe_hold(ppipe->npipe); nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); ppipe->running = 1; return (0); @@ -207,7 +207,7 @@ nni_surv_getq_cb(void *arg) if (nni_aio_result(&ppipe->aio_getq) != 0) { nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -227,7 +227,7 @@ nni_surv_send_cb(void *arg) nni_msg_free(ppipe->aio_send.a_msg); ppipe->aio_send.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -244,7 +244,7 @@ nni_surv_putq_cb(void *arg) nni_msg_free(ppipe->aio_putq.a_msg); ppipe->aio_putq.a_msg = NULL; nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); return; } @@ -288,7 +288,7 @@ nni_surv_recv_cb(void *arg) failed: nni_pipe_close(ppipe->npipe); - nni_pipe_decref(ppipe->npipe); + nni_pipe_rele(ppipe->npipe); } |
