aboutsummaryrefslogtreecommitdiff
path: root/src/core/aio.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-09-06 11:37:50 -0700
committerGarrett D'Amore <garrett@damore.org>2017-09-22 11:48:40 -0700
commit72147bcfbdc568bc58877e0904b92013d82a2acd (patch)
tree67ce22ee787b253f6b2ae9d1c68bb97d2a0450d1 /src/core/aio.c
parent2c977c35d8e44ad21345c3e91088f4f3d3f03605 (diff)
downloadnng-72147bcfbdc568bc58877e0904b92013d82a2acd.tar.gz
nng-72147bcfbdc568bc58877e0904b92013d82a2acd.tar.bz2
nng-72147bcfbdc568bc58877e0904b92013d82a2acd.zip
All AIOs are initialized. Treat NULL AIOs as noop during stop.
Diffstat (limited to 'src/core/aio.c')
-rw-r--r--src/core/aio.c17
1 files changed, 7 insertions, 10 deletions
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