aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-25 18:08:44 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-25 18:08:44 -0800
commit0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c (patch)
tree1098c7f4976033bb311b45c378079700c9330b62 /src/transport
parent64de60d98e8e4a896f9d13e4aa70343f329d88b4 (diff)
downloadnng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.gz
nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.bz2
nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.zip
Substantial fixes for listen & dialers.
At this point listening and dialing operations appear to function properly. As part of this I had to break the close logic up since otherwise we had a loop trying to reap a thread from itself. So there is now a separate reaper thread for pipes per-socket. I also changed lists to be a bit more rigid, and allocations now zero memory initially. (We had bugs due to uninitialized memory, and rather than hunt them all down, lets just init them to sane zero values.)
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/inproc/inproc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c
index 0fc0a72c..5a9c0472 100644
--- a/src/transport/inproc/inproc.c
+++ b/src/transport/inproc/inproc.c
@@ -199,8 +199,7 @@ nni_inproc_ep_create(void **epp, const char *url, uint16_t proto)
ep->mode = NNI_INPROC_EP_IDLE;
ep->closed = 0;
ep->proto = proto;
- nni_list_node_init(&nni_inproc.eps, ep);
- nni_list_append(&nni_inproc.eps, ep);
+ NNI_LIST_NODE_INIT(&ep->node);
(void) snprintf(ep->addr, sizeof (ep->addr), "%s", url);
*epp = ep;
return (0);
@@ -227,7 +226,10 @@ nni_inproc_ep_close(void *arg)
nni_mutex_enter(&nni_inproc.mx);
if (!ep->closed) {
ep->closed = 1;
- nni_list_remove(&nni_inproc.eps, ep);
+ if ((ep->mode == NNI_INPROC_EP_LISTEN) ||
+ (ep->mode == NNI_INPROC_EP_DIAL)) {
+ nni_list_remove(&nni_inproc.eps, ep);
+ }
nni_cond_broadcast(&nni_inproc.cv);
}
nni_mutex_exit(&nni_inproc.mx);
@@ -273,7 +275,6 @@ nni_inproc_ep_connect(void *arg, void **pipep)
nni_cond_wait(&nni_inproc.cv);
}
// NB: The acceptor or closer removes us from the list.
- ep->mode = NNI_INPROC_EP_IDLE;
*pipep = ep->cpipe;
nni_mutex_exit(&nni_inproc.mx);
return (ep->closed ? NNG_ECLOSED : 0);
@@ -333,7 +334,7 @@ nni_inproc_ep_accept(void *arg, void **pipep)
return (rv);
}
if (((rv = nni_msgqueue_create(&pair->q[0], 4)) != 0) ||
- ((rv = nni_msgqueue_create(&pair->q[0], 4)) != 0)) {
+ ((rv = nni_msgqueue_create(&pair->q[1], 4)) != 0)) {
nni_inproc_pair_destroy(pair);
return (rv);
}
@@ -360,6 +361,9 @@ nni_inproc_ep_accept(void *arg, void **pipep)
}
nni_cond_wait(&nni_inproc.cv);
}
+
+ nni_list_remove(&nni_inproc.eps, srch);
+ srch->mode = NNI_INPROC_EP_IDLE;
(void) snprintf(pair->addr, sizeof (pair->addr), "%s", ep->addr);
pair->pipe[0].rq = pair->pipe[1].wq = pair->q[0];
pair->pipe[1].rq = pair->pipe[0].wq = pair->q[1];