From f7463b4bd9b549a152b28aff959113b9ab56959a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 13 Jul 2017 22:19:20 -0700 Subject: Use the same pipe teardown in all circumstances. --- src/core/pipe.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core/pipe.c') diff --git a/src/core/pipe.c b/src/core/pipe.c index a912e736..aceff611 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -110,15 +110,17 @@ nni_pipe_close(nni_pipe *p) nni_mtx_unlock(&p->p_mtx); } -// We have to stop asynchronously using a task, because otherwise we can -// wind up having a callback from an AIO trying to cancel itself. That -// simply will not work. -void -nni_pipe_remove(nni_pipe *p) +// Pipe reap is called on a taskq when the pipe should be closed. No +// locks are held. This routine must take care to synchronously ensure +// that no further references to the pipe are possible, then it may +// destroy the pipe. +static void +nni_pipe_reap(nni_pipe *p) { // Transport close... nni_pipe_close(p); + // Unlink the endpoint and pipe. nni_ep_pipe_remove(p->p_ep, p); // Tell the protocol to stop. @@ -139,7 +141,7 @@ nni_pipe_stop(nni_pipe *p) } p->p_stop = 1; nni_mtx_unlock(&p->p_mtx); - nni_taskq_ent_init(&p->p_reap_tqe, (nni_cb) nni_pipe_remove, p); + nni_taskq_ent_init(&p->p_reap_tqe, (nni_cb) nni_pipe_reap, p); nni_taskq_dispatch(NULL, &p->p_reap_tqe); } -- cgit v1.2.3-70-g09d2