diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-13 22:19:20 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-13 22:19:20 -0700 |
| commit | f7463b4bd9b549a152b28aff959113b9ab56959a (patch) | |
| tree | 6f7e58b85a1c7a7ce1082d5a04068ee7272fda16 /src/core/pipe.c | |
| parent | d3de15eb854b88844071685f13cb70064d1fda49 (diff) | |
| download | nng-f7463b4bd9b549a152b28aff959113b9ab56959a.tar.gz nng-f7463b4bd9b549a152b28aff959113b9ab56959a.tar.bz2 nng-f7463b4bd9b549a152b28aff959113b9ab56959a.zip | |
Use the same pipe teardown in all circumstances.
Diffstat (limited to 'src/core/pipe.c')
| -rw-r--r-- | src/core/pipe.c | 14 |
1 files changed, 8 insertions, 6 deletions
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); } |
