diff options
| -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. |
