From bef8ea546a7efd2726f51207e26eafc75979573d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 15 Jul 2017 16:56:14 -0700 Subject: IPC race condition fixes. These mirror what we did for TCP. --- src/transport/ipc/ipc.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index a019dfbc..b799dba1 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -143,11 +143,10 @@ nni_ipc_cancel_start(nni_aio *aio) nni_ipc_pipe *pipe = aio->a_prov_data; nni_mtx_lock(&pipe->mtx); - if ((aio = pipe->user_negaio) != NULL) { - pipe->user_negaio = NULL; - nni_aio_stop(aio); - } + pipe->user_negaio = NULL; nni_mtx_unlock(&pipe->mtx); + + nni_aio_cancel(&pipe->negaio, aio->a_result); } static void @@ -325,8 +324,7 @@ nni_ipc_cancel_tx(nni_aio *aio) pipe->user_txaio = NULL; nni_mtx_unlock(&pipe->mtx); - // stop the underlying aio ... we don't want a result for it. - nni_aio_stop(&pipe->txaio); + nni_aio_cancel(&pipe->txaio, aio->a_result); } static void @@ -370,8 +368,7 @@ nni_ipc_cancel_rx(nni_aio *aio) pipe->user_rxaio = NULL; nni_mtx_unlock(&pipe->mtx); - // stop the underlying aio ... we don't want a result for it. - nni_aio_stop(&pipe->rxaio); + nni_aio_cancel(&pipe->rxaio, aio->a_result); } static void @@ -573,11 +570,10 @@ nni_ipc_cancel_ep(nni_aio *aio) nni_ipc_ep *ep = aio->a_prov_data; nni_mtx_lock(&ep->mtx); - if (ep->user_aio == aio) { - ep->user_aio = NULL; - } - nni_aio_stop(&ep->aio); + ep->user_aio = NULL; nni_mtx_unlock(&ep->mtx); + + nni_aio_cancel(&ep->aio, aio->a_result); } static void -- cgit v1.2.3-70-g09d2