aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep/rep.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-03-19 16:21:13 -0700
committerGarrett D'Amore <garrett@damore.org>2017-03-19 16:21:13 -0700
commitb8a133a9d6c5d8439c1f8ed3153d6a750aae3646 (patch)
tree0aed9586538b1330e836501612a66074093c32e8 /src/protocol/reqrep/rep.c
parent351ae4c98f65e5cbc71c27d6ab6410fb6228ca54 (diff)
downloadnng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.tar.gz
nng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.tar.bz2
nng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.zip
Eliminate p_active, better names for pipe start and stop.
Diffstat (limited to 'src/protocol/reqrep/rep.c')
-rw-r--r--src/protocol/reqrep/rep.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c
index 55a6855c..ec5b77cf 100644
--- a/src/protocol/reqrep/rep.c
+++ b/src/protocol/reqrep/rep.c
@@ -49,6 +49,7 @@ struct nni_rep_pipe {
nni_aio aio_send;
nni_aio aio_recv;
nni_aio aio_putq;
+ int running;
};
static int
@@ -168,7 +169,7 @@ nni_rep_pipe_fini(void *arg)
static int
-nni_rep_pipe_add(void *arg)
+nni_rep_pipe_start(void *arg)
{
nni_rep_pipe *rp = arg;
nni_rep_sock *rep = rp->rep;
@@ -183,19 +184,23 @@ nni_rep_pipe_add(void *arg)
nni_msgq_aio_get(rp->sendq, &rp->aio_getq);
nni_pipe_incref(rp->pipe);
nni_pipe_aio_recv(rp->pipe, &rp->aio_recv);
+ rp->running = 1;
return (0);
}
static void
-nni_rep_pipe_rem(void *arg)
+nni_rep_pipe_stop(void *arg)
{
nni_rep_pipe *rp = arg;
nni_rep_sock *rep = rp->rep;
- nni_msgq_close(rp->sendq);
- nni_msgq_aio_cancel(rep->urq, &rp->aio_putq);
- nni_idhash_remove(&rep->pipes, nni_pipe_id(rp->pipe));
+ if (rp->running) {
+ rp->running = 0;
+ nni_msgq_close(rp->sendq);
+ nni_msgq_aio_cancel(rep->urq, &rp->aio_putq);
+ nni_idhash_remove(&rep->pipes, nni_pipe_id(rp->pipe));
+ }
}
@@ -488,8 +493,8 @@ nni_rep_sock_rfilter(void *arg, nni_msg *msg)
static nni_proto_pipe_ops nni_rep_pipe_ops = {
.pipe_init = nni_rep_pipe_init,
.pipe_fini = nni_rep_pipe_fini,
- .pipe_add = nni_rep_pipe_add,
- .pipe_rem = nni_rep_pipe_rem,
+ .pipe_start = nni_rep_pipe_start,
+ .pipe_stop = nni_rep_pipe_stop,
};
static nni_proto_sock_ops nni_rep_sock_ops = {