diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-09-06 11:37:50 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-09-22 11:48:40 -0700 |
| commit | 72147bcfbdc568bc58877e0904b92013d82a2acd (patch) | |
| tree | 67ce22ee787b253f6b2ae9d1c68bb97d2a0450d1 | |
| parent | 2c977c35d8e44ad21345c3e91088f4f3d3f03605 (diff) | |
| download | nng-72147bcfbdc568bc58877e0904b92013d82a2acd.tar.gz nng-72147bcfbdc568bc58877e0904b92013d82a2acd.tar.bz2 nng-72147bcfbdc568bc58877e0904b92013d82a2acd.zip | |
All AIOs are initialized. Treat NULL AIOs as noop during stop.
| -rw-r--r-- | src/core/aio.c | 17 | ||||
| -rw-r--r-- | src/core/aio.h | 3 |
2 files changed, 8 insertions, 12 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 diff --git a/src/core/aio.h b/src/core/aio.h index 717e7995..14af4efc 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -28,7 +28,6 @@ struct nni_aio { // These fields are private to the aio framework. nni_cv a_cv; - unsigned a_init : 1; // initialized flag unsigned a_fini : 1; // shutting down (no new operations) unsigned a_done : 1; // operation has completed unsigned a_pend : 1; // completion routine pending @@ -36,7 +35,7 @@ struct nni_aio { unsigned a_expiring : 1; // expiration callback in progress unsigned a_waiting : 1; // a thread is waiting for this to finish unsigned a_synch : 1; // run completion synchronously - unsigned a_pad : 25; // ensure 32-bit alignment + unsigned a_pad : 26; // ensure 32-bit alignment nni_task a_task; // Read/write operations. |
