From 72147bcfbdc568bc58877e0904b92013d82a2acd Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 6 Sep 2017 11:37:50 -0700 Subject: All AIOs are initialized. Treat NULL AIOs as noop during stop. --- src/core/aio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/core/aio.c') diff --git a/src/core/aio.c b/src/core/aio.c index 568cd633..141499e2 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -67,7 +67,6 @@ nni_aio_init(nni_aio **aiop, nni_cb cb, void *arg) memset(aio, 0, sizeof(*aio)); nni_cv_init(&aio->a_cv, &nni_aio_lk); aio->a_expire = NNI_TIME_NEVER; - aio->a_init = 1; if (arg == NULL) { arg = aio; } @@ -105,17 +104,15 @@ nni_aio_fini_cb(nni_aio *aio) void nni_aio_stop(nni_aio *aio) { - if (!aio->a_init) { - // Never initialized, so nothing should have happened. - return; - } - nni_mtx_lock(&nni_aio_lk); - aio->a_fini = 1; - nni_mtx_unlock(&nni_aio_lk); + if (aio != NULL) { + nni_mtx_lock(&nni_aio_lk); + aio->a_fini = 1; + nni_mtx_unlock(&nni_aio_lk); - nni_aio_cancel(aio, NNG_ECANCELED); + nni_aio_cancel(aio, NNG_ECANCELED); - nni_aio_wait(aio); + nni_aio_wait(aio); + } } void -- cgit v1.2.3-70-g09d2