From d7f7c896c0ede24249ef63b1e45b1878bf4bd473 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 31 Jul 2018 12:33:58 -0700 Subject: fixes #599 nng_dial sync should not return until added to socket fixes #208 pipe start should occur before connect / accept fixes #616 Race condition closing between header & body This refactors the transports to handle their own connection handshaking before passing the pipe to the socket. This changes and simplifies the setup. This also fixes a rather challenging race condition described by #616. --- src/core/aio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/core/aio.c') diff --git a/src/core/aio.c b/src/core/aio.c index 40638bce..294a0b92 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -217,11 +217,17 @@ void nni_aio_stop(nni_aio *aio) { if (aio != NULL) { + nni_aio_cancelfn cancelfn; + nni_mtx_lock(&nni_aio_lk); - aio->a_stop = true; + cancelfn = aio->a_prov_cancel; + aio->a_prov_cancel = NULL; + aio->a_stop = true; nni_mtx_unlock(&nni_aio_lk); - nni_aio_abort(aio, NNG_ECANCELED); + if (cancelfn != NULL) { + cancelfn(aio, NNG_ECANCELED); + } nni_aio_wait(aio); } -- cgit v1.2.3-70-g09d2