From 55e98ae58c5856c1808e3fccb2548a76c9b8907c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 12 Mar 2018 17:37:33 -0700 Subject: nng_sleep_aio should honor aio timeout. The first problem was that using nng_sleep_aio was found to reset the timeout, and this caused subsequent operations to start failing with timeouts when reusing the AIO for other operations. The second thing is that we think it would be nicer if the presence of real aio timeouts were still honored, so that if the timeout is shorter than the sleep time, then we get back an NNG_ETIMEDOUT like every other operation, and we get back a 0 if the logical sleep operation completes normally. --- tests/aio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/aio.c b/tests/aio.c index b57c5a69..244ae3b9 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -56,6 +56,25 @@ Main({ So((nng_clock() - start) <= 1000); nng_aio_free(saio); }); + + Convey("Sleep timeout works", { + nng_time start = 0; + nng_time end = 0; + nng_aio *saio; + So(nng_aio_alloc(&saio, sleepdone, &end) == 0); + nng_aio_set_timeout(saio, 100); + start = nng_clock(); + nng_sleep_aio(2000, saio); + nng_aio_wait(saio); + So(nng_aio_result(saio) == NNG_ETIMEDOUT); + So(end != 0); + So((end - start) >= 100); + So((end - start) <= 1000); + So((nng_clock() - start) >= 100); + So((nng_clock() - start) <= 1000); + nng_aio_free(saio); + }); + Convey("Given a connected pair of sockets", { nng_socket s1; nng_socket s2; -- cgit v1.2.3-70-g09d2