From c72bd53e2c5b4bc7207bfa1710ccff47655a099a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 20 Aug 2018 11:09:23 -0700 Subject: fixes #506 AIO "providers" need a way to call nni_aio_schedule. --- tests/aio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') 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(); -- cgit v1.2.3-70-g09d2