diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-18 20:23:14 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-18 20:23:14 -0700 |
| commit | 9a224b54913818db3080b13cc1183d5bb3926247 (patch) | |
| tree | 211ef8425d6bf9d79dea539c92940c1286c61286 /src/transport/ipc | |
| parent | 5fb832e06fd4ded6ccc45f943837fd374a9cea7a (diff) | |
| download | nng-9a224b54913818db3080b13cc1183d5bb3926247.tar.gz nng-9a224b54913818db3080b13cc1183d5bb3926247.tar.bz2 nng-9a224b54913818db3080b13cc1183d5bb3926247.zip | |
fixes #21 Crash in IPC (POSIX)
This resolves the orphaned pipedesc, which actually could have affected
Windows too. I think maybe we are race free. Lots more testing is
still required, but stress runs seem to be passing now.
Diffstat (limited to 'src/transport/ipc')
| -rw-r--r-- | src/transport/ipc/ipc.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index 862cf955..65266ccc 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -527,14 +527,10 @@ nni_ipc_ep_bind(void *arg) static void nni_ipc_ep_finish(nni_ipc_ep *ep) { - nni_aio * aio = ep->user_aio; - nni_ipc_pipe *pipe; + nni_aio * aio; int rv; + nni_ipc_pipe *pipe = NULL; - if ((aio = ep->user_aio) == NULL) { - return; - } - ep->user_aio = NULL; if ((rv = nni_aio_result(&ep->aio)) != 0) { goto done; } @@ -542,17 +538,15 @@ nni_ipc_ep_finish(nni_ipc_ep *ep) // Attempt to allocate the parent pipe. If this fails we'll // drop the connection (ENOMEM probably). - if ((rv = nni_ipc_pipe_init(&pipe, ep, ep->aio.a_pipe)) != 0) { - nni_plat_ipc_pipe_fini(ep->aio.a_pipe); - goto done; - } - - aio->a_pipe = pipe; + rv = nni_ipc_pipe_init(&pipe, ep, ep->aio.a_pipe); done: ep->aio.a_pipe = NULL; - if (nni_aio_finish(aio, rv, 0) != 0) { - if (rv == 0) { + aio = ep->user_aio; + ep->user_aio = NULL; + + if ((aio == NULL) || (nni_aio_finish_pipe(aio, rv, pipe) != 0)) { + if (pipe != NULL) { nni_ipc_pipe_fini(pipe); } } |
