aboutsummaryrefslogtreecommitdiff
path: root/src/core/pipe.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-30 21:41:40 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-01 12:27:19 -0700
commit4998964a435fe0f02a2d81b01fdb837214674e72 (patch)
treedc5fe29da0574fc1510ab6f9b23b54ffd68cd97b /src/core/pipe.c
parent63bdb2c28bc185096e579d1922d57cb71ecaa36b (diff)
downloadnng-4998964a435fe0f02a2d81b01fdb837214674e72.tar.gz
nng-4998964a435fe0f02a2d81b01fdb837214674e72.tar.bz2
nng-4998964a435fe0f02a2d81b01fdb837214674e72.zip
fixes #381 Want comparators for various types
Diffstat (limited to 'src/core/pipe.c')
-rw-r--r--src/core/pipe.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c
index a4148c65..c619fca0 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -26,7 +26,7 @@ struct nni_pipe {
nni_list_node p_ep_node;
nni_sock * p_sock;
nni_ep * p_ep;
- int p_reap;
+ bool p_reap;
int p_stop;
int p_refcnt;
nni_mtx p_mtx;
@@ -142,8 +142,12 @@ nni_pipe_find(nni_pipe **pp, uint32_t id)
nni_pipe *p;
nni_mtx_lock(&nni_pipe_lk);
if ((rv = nni_idhash_find(nni_pipes, id, (void **) &p)) == 0) {
- p->p_refcnt++;
- *pp = p;
+ if (p->p_reap) {
+ rv = NNG_ECLOSED;
+ } else {
+ p->p_refcnt++;
+ *pp = p;
+ }
}
nni_mtx_unlock(&nni_pipe_lk);
return (rv);
@@ -186,12 +190,12 @@ void
nni_pipe_close(nni_pipe *p)
{
nni_mtx_lock(&p->p_mtx);
- if (p->p_reap == 1) {
+ if (p->p_reap) {
// We already did a close.
nni_mtx_unlock(&p->p_mtx);
return;
}
- p->p_reap = 1;
+ p->p_reap = true;
// Close the underlying transport.
if (p->p_tran_data != NULL) {
@@ -267,6 +271,7 @@ nni_pipe_create(nni_ep *ep, void *tdata)
p->p_proto_data = NULL;
p->p_ep = ep;
p->p_sock = sock;
+ p->p_reap = false;
NNI_LIST_NODE_INIT(&p->p_reap_node);
NNI_LIST_NODE_INIT(&p->p_sock_node);