diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-08-20 11:09:23 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-20 11:09:23 -0700 |
| commit | c72bd53e2c5b4bc7207bfa1710ccff47655a099a (patch) | |
| tree | f85e26882244430c41930c45d83887d5b01969cc /tests | |
| parent | 6e5f6a26beec0a44d25625cacb5095cdc7a94146 (diff) | |
| download | nng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.tar.gz nng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.tar.bz2 nng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.zip | |
fixes #506 AIO "providers" need a way to call nni_aio_schedule.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aio.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/aio.c b/tests/aio.c index bd5c5097..0efc013a 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -35,6 +35,13 @@ sleepdone(void *arg) *(nng_time *) arg = nng_clock(); } +void +cancelfn(nng_aio *aio, void *arg, int rv) +{ + *(int *) arg = rv; + nng_aio_finish(aio, rv); +} + Main({ Test("AIO operations", { const char *addr = "inproc://aio"; @@ -179,6 +186,19 @@ Main({ So(nng_aio_set_iov(aio, 1024, &iov) == NNG_EINVAL); nng_aio_free(aio); }); + + Convey("Provider cancellation works", { + nng_aio *aio; + int rv = 0; + // We fake an empty provider that does not do anything. + So(nng_aio_alloc(&aio, NULL, NULL) == 0); + So(nng_aio_begin(aio) == true); + nng_aio_defer(aio, cancelfn, &rv); + nng_aio_cancel(aio); + nng_aio_wait(aio); + So(rv == NNG_ECANCELED); + nng_aio_free(aio); + }); }); nng_fini(); |
