aboutsummaryrefslogtreecommitdiff
path: root/src/transport/inproc/inproc.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-15 18:45:02 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-15 18:45:02 -0700
commita1d237059c652c9e36117eed3e6387dcae128174 (patch)
treed0f0d25f803ba9b1fadcc33507116aba56dc1a6d /src/transport/inproc/inproc.c
parentbb974dcfa8a22cdf528b6035ab5226f6691f0abf (diff)
downloadnng-a1d237059c652c9e36117eed3e6387dcae128174.tar.gz
nng-a1d237059c652c9e36117eed3e6387dcae128174.tar.bz2
nng-a1d237059c652c9e36117eed3e6387dcae128174.zip
Add missing cancellation for inproc endpoints -- the source of much woe.
Most of the races around close were probably here - the cancellation was not getting through on endpoint close, which meant that we could actually toss endpoints while they were in use. We need to fix the timeouts stuff -- especially for reconnects etc, but we are just about ready for this stuff to be reintegrated into master.
Diffstat (limited to 'src/transport/inproc/inproc.c')
-rw-r--r--src/transport/inproc/inproc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c
index 78a0c44a..984ee8f5 100644
--- a/src/transport/inproc/inproc.c
+++ b/src/transport/inproc/inproc.c
@@ -364,6 +364,24 @@ nni_inproc_accept_clients(nni_inproc_ep *server)
}
static void
+nni_inproc_ep_cancel(nni_aio *aio)
+{
+ nni_inproc_ep *ep = aio->a_prov_data;
+
+ nni_mtx_lock(&nni_inproc.mx);
+ if (nni_list_active(&ep->aios, aio)) {
+ nni_list_remove(&ep->aios, aio);
+ }
+ // Arguably if the mode is a client... then we need to remove
+ // it from the server's list. Notably this isn't *our* list,
+ // but the offsets are the same and they're good enough using the
+ // global lock to make it all safe.
+ if (nni_list_active(&ep->clients, ep)) {
+ nni_list_remove(&ep->clients, ep);
+ }
+ nni_mtx_unlock(&nni_inproc.mx);
+}
+static void
nni_inproc_ep_connect(void *arg, nni_aio *aio)
{
nni_inproc_ep * ep = arg;
@@ -390,6 +408,11 @@ nni_inproc_ep_connect(void *arg, nni_aio *aio)
}
nni_mtx_lock(&nni_inproc.mx);
+
+ if ((rv = nni_aio_start(aio, nni_inproc_ep_cancel, ep)) != 0) {
+ nni_mtx_unlock(&nni_inproc.mx);
+ return;
+ }
aio->a_pipe = pipe;
if (nni_list_active(&ep->clients, ep)) {
@@ -491,6 +514,10 @@ nni_inproc_ep_accept(void *arg, nni_aio *aio)
return;
}
+ if ((rv = nni_aio_start(aio, nni_inproc_ep_cancel, ep)) != 0) {
+ nni_mtx_unlock(&nni_inproc.mx);
+ return;
+ }
aio->a_pipe = pipe;
// Insert us into the pending server aios, and then run the