aboutsummaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-15 01:47:12 -0700
committerGitHub <noreply@github.com>2018-05-15 01:47:12 -0700
commit1d033484ee1a2ec26d3eead073e7bc0f889ffdf4 (patch)
tree15d3897d405cb0beb1ada6270ecf70241451ca70 /src/protocol
parent16b4c4019c7b7904de171c588ed8c72ca732d2cf (diff)
downloadnng-1d033484ee1a2ec26d3eead073e7bc0f889ffdf4.tar.gz
nng-1d033484ee1a2ec26d3eead073e7bc0f889ffdf4.tar.bz2
nng-1d033484ee1a2ec26d3eead073e7bc0f889ffdf4.zip
fixes #419 want to nni_aio_stop without blocking (#428)
* fixes #419 want to nni_aio_stop without blocking This actually introduces an nni_aio_close() API that causes nni_aio_begin to return NNG_ECLOSED, while scheduling a callback on the AIO to do an NNG_ECLOSED as well. This should be called in non-blocking close() contexts instead of nni_aio_stop(), and the cases where we call nni_aio_fini() multiple times are updated updated to add nni_aio_stop() calls on all "interlinked" aios before finalizing them. Furthermore, we call nni_aio_close() as soon as practical in the close path. This closes an annoying race condition where the callback from a lower subsystem could wind up rescheduling an operation that we wanted to abort.
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/bus0/bus.c26
-rw-r--r--src/protocol/pair0/pair.c22
-rw-r--r--src/protocol/pair1/pair.c27
-rw-r--r--src/protocol/pipeline0/pull.c16
-rw-r--r--src/protocol/pipeline0/push.c19
-rw-r--r--src/protocol/pubsub0/pub.c23
-rw-r--r--src/protocol/pubsub0/sub.c16
-rw-r--r--src/protocol/reqrep0/rep.c16
-rw-r--r--src/protocol/reqrep0/req.c19
-rw-r--r--src/protocol/reqrep0/xrep.c25
-rw-r--r--src/protocol/reqrep0/xreq.c25
-rw-r--r--src/protocol/survey0/respond.c18
-rw-r--r--src/protocol/survey0/survey.c19
-rw-r--r--src/protocol/survey0/xrespond.c26
-rw-r--r--src/protocol/survey0/xsurvey.c25
15 files changed, 241 insertions, 81 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c
index 2a2a1228..01f20130 100644
--- a/src/protocol/bus0/bus.c
+++ b/src/protocol/bus0/bus.c
@@ -67,7 +67,6 @@ bus0_sock_fini(void *arg)
{
bus0_sock *s = arg;
- nni_aio_stop(s->aio_getq);
nni_aio_fini(s->aio_getq);
nni_mtx_fini(&s->mtx);
NNI_FREE_STRUCT(s);
@@ -108,7 +107,18 @@ bus0_sock_close(void *arg)
{
bus0_sock *s = arg;
- nni_aio_abort(s->aio_getq, NNG_ECLOSED);
+ nni_aio_close(s->aio_getq);
+}
+
+static void
+bus0_pipe_stop(void *arg)
+{
+ bus0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_putq);
}
static void
@@ -168,18 +178,17 @@ bus0_pipe_start(void *arg)
}
static void
-bus0_pipe_stop(void *arg)
+bus0_pipe_close(void *arg)
{
bus0_pipe *p = arg;
bus0_sock *s = p->psock;
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_putq);
nni_msgq_close(p->sendq);
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
-
nni_mtx_lock(&s->mtx);
if (nni_list_active(&s->pipes, p)) {
nni_list_remove(&s->pipes, p);
@@ -351,6 +360,7 @@ static nni_proto_pipe_ops bus0_pipe_ops = {
.pipe_init = bus0_pipe_init,
.pipe_fini = bus0_pipe_fini,
.pipe_start = bus0_pipe_start,
+ .pipe_close = bus0_pipe_close,
.pipe_stop = bus0_pipe_stop,
};
diff --git a/src/protocol/pair0/pair.c b/src/protocol/pair0/pair.c
index e275e52c..2fb42df5 100644
--- a/src/protocol/pair0/pair.c
+++ b/src/protocol/pair0/pair.c
@@ -78,6 +78,17 @@ pair0_sock_fini(void *arg)
}
static void
+pair0_pipe_stop(void *arg)
+{
+ pair0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_putq);
+ nni_aio_stop(p->aio_getq);
+}
+
+static void
pair0_pipe_fini(void *arg)
{
pair0_pipe *p = arg;
@@ -135,15 +146,15 @@ pair0_pipe_start(void *arg)
}
static void
-pair0_pipe_stop(void *arg)
+pair0_pipe_close(void *arg)
{
pair0_pipe *p = arg;
pair0_sock *s = p->psock;
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_putq);
+ nni_aio_close(p->aio_getq);
nni_mtx_lock(&s->mtx);
if (s->ppipe == p) {
@@ -249,6 +260,7 @@ static nni_proto_pipe_ops pair0_pipe_ops = {
.pipe_init = pair0_pipe_init,
.pipe_fini = pair0_pipe_fini,
.pipe_start = pair0_pipe_start,
+ .pipe_close = pair0_pipe_close,
.pipe_stop = pair0_pipe_stop,
};
diff --git a/src/protocol/pair1/pair.c b/src/protocol/pair1/pair.c
index a3c01d46..ab01e451 100644
--- a/src/protocol/pair1/pair.c
+++ b/src/protocol/pair1/pair.c
@@ -117,9 +117,21 @@ pair1_sock_init_raw(void **sp, nni_sock *nsock)
}
static void
+pair1_pipe_stop(void *arg)
+{
+ pair1_pipe *p = arg;
+
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_putq);
+ nni_aio_stop(p->aio_getq);
+}
+
+static void
pair1_pipe_fini(void *arg)
{
pair1_pipe *p = arg;
+
nni_aio_fini(p->aio_send);
nni_aio_fini(p->aio_recv);
nni_aio_fini(p->aio_putq);
@@ -198,21 +210,22 @@ pair1_pipe_start(void *arg)
}
static void
-pair1_pipe_stop(void *arg)
+pair1_pipe_close(void *arg)
{
pair1_pipe *p = arg;
pair1_sock *s = p->psock;
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_putq);
+ nni_aio_close(p->aio_getq);
+
nni_mtx_lock(&s->mtx);
nni_idhash_remove(s->pipes, nni_pipe_id(p->npipe));
nni_list_node_remove(&p->node);
nni_mtx_unlock(&s->mtx);
nni_msgq_close(p->sendq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_getq);
}
static void
@@ -405,7 +418,8 @@ pair1_sock_open(void *arg)
static void
pair1_sock_close(void *arg)
{
- NNI_ARG_UNUSED(arg);
+ pair1_sock *s = arg;
+ nni_aio_close(s->aio_getq);
}
static int
@@ -464,6 +478,7 @@ static nni_proto_pipe_ops pair1_pipe_ops = {
.pipe_init = pair1_pipe_init,
.pipe_fini = pair1_pipe_fini,
.pipe_start = pair1_pipe_start,
+ .pipe_close = pair1_pipe_close,
.pipe_stop = pair1_pipe_stop,
};
diff --git a/src/protocol/pipeline0/pull.c b/src/protocol/pipeline0/pull.c
index c5017d50..81f6c137 100644
--- a/src/protocol/pipeline0/pull.c
+++ b/src/protocol/pipeline0/pull.c
@@ -68,6 +68,15 @@ pull0_sock_fini(void *arg)
}
static void
+pull0_pipe_stop(void *arg)
+{
+ pull0_pipe *p = arg;
+
+ nni_aio_stop(p->putq_aio);
+ nni_aio_stop(p->recv_aio);
+}
+
+static void
pull0_pipe_fini(void *arg)
{
pull0_pipe *p = arg;
@@ -110,12 +119,12 @@ pull0_pipe_start(void *arg)
}
static void
-pull0_pipe_stop(void *arg)
+pull0_pipe_close(void *arg)
{
pull0_pipe *p = arg;
- nni_aio_stop(p->putq_aio);
- nni_aio_stop(p->recv_aio);
+ nni_aio_close(p->putq_aio);
+ nni_aio_close(p->recv_aio);
}
static void
@@ -198,6 +207,7 @@ static nni_proto_pipe_ops pull0_pipe_ops = {
.pipe_init = pull0_pipe_init,
.pipe_fini = pull0_pipe_fini,
.pipe_start = pull0_pipe_start,
+ .pipe_close = pull0_pipe_close,
.pipe_stop = pull0_pipe_stop,
};
diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c
index 2ad657b6..e413cf46 100644
--- a/src/protocol/pipeline0/push.c
+++ b/src/protocol/pipeline0/push.c
@@ -83,6 +83,16 @@ push0_sock_close(void *arg)
}
static void
+push0_pipe_stop(void *arg)
+{
+ push0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_getq);
+}
+
+static void
push0_pipe_fini(void *arg)
{
push0_pipe *p = arg;
@@ -136,13 +146,13 @@ push0_pipe_start(void *arg)
}
static void
-push0_pipe_stop(void *arg)
+push0_pipe_close(void *arg)
{
push0_pipe *p = arg;
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_getq);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_getq);
}
static void
@@ -214,6 +224,7 @@ static nni_proto_pipe_ops push0_pipe_ops = {
.pipe_init = push0_pipe_init,
.pipe_fini = push0_pipe_fini,
.pipe_start = push0_pipe_start,
+ .pipe_close = push0_pipe_close,
.pipe_stop = push0_pipe_stop,
};
diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c
index 45f4b7d9..4db48754 100644
--- a/src/protocol/pubsub0/pub.c
+++ b/src/protocol/pubsub0/pub.c
@@ -61,7 +61,6 @@ pub0_sock_fini(void *arg)
{
pub0_sock *s = arg;
- nni_aio_stop(s->aio_getq);
nni_aio_fini(s->aio_getq);
nni_mtx_fini(&s->mtx);
NNI_FREE_STRUCT(s);
@@ -103,13 +102,24 @@ pub0_sock_close(void *arg)
{
pub0_sock *s = arg;
- nni_aio_abort(s->aio_getq, NNG_ECLOSED);
+ nni_aio_close(s->aio_getq);
+}
+
+static void
+pub0_pipe_stop(void *arg)
+{
+ pub0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
}
static void
pub0_pipe_fini(void *arg)
{
pub0_pipe *p = arg;
+
nni_aio_fini(p->aio_getq);
nni_aio_fini(p->aio_send);
nni_aio_fini(p->aio_recv);
@@ -164,14 +174,14 @@ pub0_pipe_start(void *arg)
}
static void
-pub0_pipe_stop(void *arg)
+pub0_pipe_close(void *arg)
{
pub0_pipe *p = arg;
pub0_sock *s = p->pub;
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
nni_msgq_close(p->sendq);
@@ -290,6 +300,7 @@ static nni_proto_pipe_ops pub0_pipe_ops = {
.pipe_init = pub0_pipe_init,
.pipe_fini = pub0_pipe_fini,
.pipe_start = pub0_pipe_start,
+ .pipe_close = pub0_pipe_close,
.pipe_stop = pub0_pipe_stop,
};
diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c
index b41b33ea..c244b0ad 100644
--- a/src/protocol/pubsub0/sub.c
+++ b/src/protocol/pubsub0/sub.c
@@ -99,6 +99,15 @@ sub0_sock_close(void *arg)
}
static void
+sub0_pipe_stop(void *arg)
+{
+ sub0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_putq);
+ nni_aio_stop(p->aio_recv);
+}
+
+static void
sub0_pipe_fini(void *arg)
{
sub0_pipe *p = arg;
@@ -139,12 +148,12 @@ sub0_pipe_start(void *arg)
}
static void
-sub0_pipe_stop(void *arg)
+sub0_pipe_close(void *arg)
{
sub0_pipe *p = arg;
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_recv);
+ nni_aio_close(p->aio_putq);
+ nni_aio_close(p->aio_recv);
}
static void
@@ -338,6 +347,7 @@ static nni_proto_pipe_ops sub0_pipe_ops = {
.pipe_init = sub0_pipe_init,
.pipe_fini = sub0_pipe_fini,
.pipe_start = sub0_pipe_start,
+ .pipe_close = sub0_pipe_close,
.pipe_stop = sub0_pipe_stop,
};
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c
index 965cbea7..c483b777 100644
--- a/src/protocol/reqrep0/rep.c
+++ b/src/protocol/reqrep0/rep.c
@@ -297,6 +297,15 @@ rep0_sock_close(void *arg)
}
static void
+rep0_pipe_stop(void *arg)
+{
+ rep0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+}
+
+static void
rep0_pipe_fini(void *arg)
{
rep0_pipe *p = arg;
@@ -347,14 +356,14 @@ rep0_pipe_start(void *arg)
}
static void
-rep0_pipe_stop(void *arg)
+rep0_pipe_close(void *arg)
{
rep0_pipe *p = arg;
rep0_sock *s = p->rep;
rep0_ctx * ctx;
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
nni_mtx_lock(&s->lk);
if (nni_list_active(&s->recvpipes, p)) {
@@ -647,6 +656,7 @@ static nni_proto_pipe_ops rep0_pipe_ops = {
.pipe_init = rep0_pipe_init,
.pipe_fini = rep0_pipe_fini,
.pipe_start = rep0_pipe_start,
+ .pipe_close = rep0_pipe_close,
.pipe_stop = rep0_pipe_stop,
};
diff --git a/src/protocol/reqrep0/req.c b/src/protocol/reqrep0/req.c
index bbb0b886..fc9d7271 100644
--- a/src/protocol/reqrep0/req.c
+++ b/src/protocol/reqrep0/req.c
@@ -186,6 +186,15 @@ req0_sock_fini(void *arg)
}
static void
+req0_pipe_stop(void *arg)
+{
+ req0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_send);
+}
+
+static void
req0_pipe_fini(void *arg)
{
req0_pipe *p = arg;
@@ -243,17 +252,14 @@ req0_pipe_start(void *arg)
}
static void
-req0_pipe_stop(void *arg)
+req0_pipe_close(void *arg)
{
req0_pipe *p = arg;
req0_sock *s = p->req;
req0_ctx * ctx;
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_send);
-
- // At this point there should not be any further AIOs running.
- // Further, any completion tasks have completed.
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_send);
nni_mtx_lock(&s->mtx);
// This removes the node from either busypipes or readypipes.
@@ -837,6 +843,7 @@ static nni_proto_pipe_ops req0_pipe_ops = {
.pipe_init = req0_pipe_init,
.pipe_fini = req0_pipe_fini,
.pipe_start = req0_pipe_start,
+ .pipe_close = req0_pipe_close,
.pipe_stop = req0_pipe_stop,
};
diff --git a/src/protocol/reqrep0/xrep.c b/src/protocol/reqrep0/xrep.c
index 4773677e..6dcfe6be 100644
--- a/src/protocol/reqrep0/xrep.c
+++ b/src/protocol/reqrep0/xrep.c
@@ -62,7 +62,6 @@ xrep0_sock_fini(void *arg)
{
xrep0_sock *s = arg;
- nni_aio_stop(s->aio_getq);
nni_aio_fini(s->aio_getq);
nni_idhash_fini(s->pipes);
nni_mtx_fini(&s->lk);
@@ -108,7 +107,18 @@ xrep0_sock_close(void *arg)
{
xrep0_sock *s = arg;
- nni_aio_abort(s->aio_getq, NNG_ECLOSED);
+ nni_aio_close(s->aio_getq);
+}
+
+static void
+xrep0_pipe_stop(void *arg)
+{
+ xrep0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_putq);
}
static void
@@ -178,16 +188,16 @@ xrep0_pipe_start(void *arg)
}
static void
-xrep0_pipe_stop(void *arg)
+xrep0_pipe_close(void *arg)
{
xrep0_pipe *p = arg;
xrep0_sock *s = p->rep;
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_putq);
nni_msgq_close(p->sendq);
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
nni_mtx_lock(&s->lk);
nni_idhash_remove(s->pipes, nni_pipe_id(p->pipe));
@@ -389,6 +399,7 @@ static nni_proto_pipe_ops xrep0_pipe_ops = {
.pipe_init = xrep0_pipe_init,
.pipe_fini = xrep0_pipe_fini,
.pipe_start = xrep0_pipe_start,
+ .pipe_close = xrep0_pipe_close,
.pipe_stop = xrep0_pipe_stop,
};
diff --git a/src/protocol/reqrep0/xreq.c b/src/protocol/reqrep0/xreq.c
index 13ae7418..793411af 100644
--- a/src/protocol/reqrep0/xreq.c
+++ b/src/protocol/reqrep0/xreq.c
@@ -90,6 +90,17 @@ xreq0_sock_fini(void *arg)
}
static void
+xreq0_pipe_stop(void *arg)
+{
+ xreq0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_putq);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_send);
+}
+
+static void
xreq0_pipe_fini(void *arg)
{
xreq0_pipe *p = arg;
@@ -140,17 +151,14 @@ xreq0_pipe_start(void *arg)
}
static void
-xreq0_pipe_stop(void *arg)
+xreq0_pipe_close(void *arg)
{
xreq0_pipe *p = arg;
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_send);
-
- // At this point there should not be any further AIOs running.
- // Further, any completion tasks have completed.
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_putq);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_send);
}
// For raw mode we can just let the pipes "contend" via getq to get a
@@ -277,6 +285,7 @@ static nni_proto_pipe_ops xreq0_pipe_ops = {
.pipe_init = xreq0_pipe_init,
.pipe_fini = xreq0_pipe_fini,
.pipe_start = xreq0_pipe_start,
+ .pipe_close = xreq0_pipe_close,
.pipe_stop = xreq0_pipe_stop,
};
diff --git a/src/protocol/survey0/respond.c b/src/protocol/survey0/respond.c
index e553f6ce..7738a8b7 100644
--- a/src/protocol/survey0/respond.c
+++ b/src/protocol/survey0/respond.c
@@ -290,6 +290,15 @@ resp0_sock_close(void *arg)
}
static void
+resp0_pipe_stop(void *arg)
+{
+ resp0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+}
+
+static void
resp0_pipe_fini(void *arg)
{
resp0_pipe *p = arg;
@@ -344,12 +353,15 @@ resp0_pipe_start(void *arg)
}
static void
-resp0_pipe_stop(void *arg)
+resp0_pipe_close(void *arg)
{
resp0_pipe *p = arg;
resp0_sock *s = p->psock;
resp0_ctx * ctx;
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+
nni_mtx_lock(&s->mtx);
while ((ctx = nni_list_first(&p->sendq)) != NULL) {
nni_aio *aio;
@@ -369,9 +381,6 @@ resp0_pipe_stop(void *arg)
}
nni_idhash_remove(s->pipes, p->id);
nni_mtx_unlock(&s->mtx);
-
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
}
static void
@@ -626,6 +635,7 @@ static nni_proto_pipe_ops resp0_pipe_ops = {
.pipe_init = resp0_pipe_init,
.pipe_fini = resp0_pipe_fini,
.pipe_start = resp0_pipe_start,
+ .pipe_close = resp0_pipe_close,
.pipe_stop = resp0_pipe_stop,
};
diff --git a/src/protocol/survey0/survey.c b/src/protocol/survey0/survey.c
index e725d2b3..51bce0c8 100644
--- a/src/protocol/survey0/survey.c
+++ b/src/protocol/survey0/survey.c
@@ -284,6 +284,16 @@ surv0_sock_close(void *arg)
}
static void
+surv0_pipe_stop(void *arg)
+{
+ surv0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+}
+
+static void
surv0_pipe_fini(void *arg)
{
surv0_pipe *p = arg;
@@ -338,14 +348,14 @@ surv0_pipe_start(void *arg)
}
static void
-surv0_pipe_stop(void *arg)
+surv0_pipe_close(void *arg)
{
surv0_pipe *p = arg;
surv0_sock *s = p->sock;
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
nni_msgq_close(p->sendq);
@@ -532,6 +542,7 @@ static nni_proto_pipe_ops surv0_pipe_ops = {
.pipe_init = surv0_pipe_init,
.pipe_fini = surv0_pipe_fini,
.pipe_start = surv0_pipe_start,
+ .pipe_close = surv0_pipe_close,
.pipe_stop = surv0_pipe_stop,
};
diff --git a/src/protocol/survey0/xrespond.c b/src/protocol/survey0/xrespond.c
index 7aaed6da..bcbbcbc7 100644
--- a/src/protocol/survey0/xrespond.c
+++ b/src/protocol/survey0/xrespond.c
@@ -63,7 +63,6 @@ xresp0_sock_fini(void *arg)
{
xresp0_sock *s = arg;
- nni_aio_stop(s->aio_getq);
nni_aio_fini(s->aio_getq);
nni_idhash_fini(s->pipes);
nni_mtx_fini(&s->mtx);
@@ -107,7 +106,18 @@ xresp0_sock_close(void *arg)
{
xresp0_sock *s = arg;
- nni_aio_abort(s->aio_getq, NNG_ECLOSED);
+ nni_aio_close(s->aio_getq);
+}
+
+static void
+xresp0_pipe_stop(void *arg)
+{
+ xresp0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_putq);
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
}
static void
@@ -170,16 +180,17 @@ xresp0_pipe_start(void *arg)
}
static void
-xresp0_pipe_stop(void *arg)
+xresp0_pipe_close(void *arg)
{
xresp0_pipe *p = arg;
xresp0_sock *s = p->psock;
+ nni_aio_close(p->aio_putq);
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+
nni_msgq_close(p->sendq);
- nni_aio_stop(p->aio_putq);
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
nni_mtx_lock(&s->mtx);
nni_idhash_remove(s->pipes, p->id);
@@ -366,6 +377,7 @@ static nni_proto_pipe_ops xresp0_pipe_ops = {
.pipe_init = xresp0_pipe_init,
.pipe_fini = xresp0_pipe_fini,
.pipe_start = xresp0_pipe_start,
+ .pipe_close = xresp0_pipe_close,
.pipe_stop = xresp0_pipe_stop,
};
diff --git a/src/protocol/survey0/xsurvey.c b/src/protocol/survey0/xsurvey.c
index cf311b15..47ebef3c 100644
--- a/src/protocol/survey0/xsurvey.c
+++ b/src/protocol/survey0/xsurvey.c
@@ -61,7 +61,6 @@ xsurv0_sock_fini(void *arg)
{
xsurv0_sock *s = arg;
- nni_aio_stop(s->aio_getq);
nni_aio_fini(s->aio_getq);
nni_mtx_fini(&s->mtx);
NNI_FREE_STRUCT(s);
@@ -104,7 +103,18 @@ xsurv0_sock_close(void *arg)
{
xsurv0_sock *s = arg;
- nni_aio_abort(s->aio_getq, NNG_ECLOSED);
+ nni_aio_close(s->aio_getq);
+}
+
+static void
+xsurv0_pipe_stop(void *arg)
+{
+ xsurv0_pipe *p = arg;
+
+ nni_aio_stop(p->aio_getq);
+ nni_aio_stop(p->aio_send);
+ nni_aio_stop(p->aio_recv);
+ nni_aio_stop(p->aio_putq);
}
static void
@@ -166,15 +176,15 @@ xsurv0_pipe_start(void *arg)
}
static void
-xsurv0_pipe_stop(void *arg)
+xsurv0_pipe_close(void *arg)
{
xsurv0_pipe *p = arg;
xsurv0_sock *s = p->psock;
- nni_aio_stop(p->aio_getq);
- nni_aio_stop(p->aio_send);
- nni_aio_stop(p->aio_recv);
- nni_aio_stop(p->aio_putq);
+ nni_aio_close(p->aio_getq);
+ nni_aio_close(p->aio_send);
+ nni_aio_close(p->aio_recv);
+ nni_aio_close(p->aio_putq);
nni_msgq_close(p->sendq);
@@ -338,6 +348,7 @@ static nni_proto_pipe_ops xsurv0_pipe_ops = {
.pipe_init = xsurv0_pipe_init,
.pipe_fini = xsurv0_pipe_fini,
.pipe_start = xsurv0_pipe_start,
+ .pipe_close = xsurv0_pipe_close,
.pipe_stop = xsurv0_pipe_stop,
};