From 838c9eab97c9d954354db711faae8a1fa6c12d38 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 30 Dec 2023 19:35:24 -0800 Subject: fixes #1751 Support nng_aio_set_expire(). While here fixed a number of nits in comments. --- src/core/aio_test.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/aio_test.c b/src/core/aio_test.c index bbc997b5..fb0f5c34 100644 --- a/src/core/aio_test.c +++ b/src/core/aio_test.c @@ -1,5 +1,5 @@ // -// Copyright 2022 Staysail Systems, Inc. +// Copyright 2023 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -190,6 +190,27 @@ test_explicit_timeout(void) NUTS_PASS(nng_close(s)); } +void +test_explicit_expiration(void) +{ + nng_socket s; + nng_aio * a; + int done = 0; + nng_time now; + + NUTS_PASS(nng_pair1_open(&s)); + NUTS_PASS(nng_aio_alloc(&a, cb_done, &done)); + now = nng_clock(); + now += 40; + nng_aio_set_expire(a, now); + nng_recv_aio(s, a); + nng_aio_wait(a); + NUTS_TRUE(done == 1); + NUTS_FAIL(nng_aio_result(a), NNG_ETIMEDOUT); + nng_aio_free(a); + NUTS_PASS(nng_close(s)); +} + void test_inherited_timeout(void) { @@ -384,6 +405,7 @@ NUTS_TESTS = { { "consumer cancel", test_consumer_cancel }, { "traffic", test_traffic }, { "explicit timeout", test_explicit_timeout }, + { "explicit expire", test_explicit_expiration }, { "inherited timeout", test_inherited_timeout }, { "zero timeout", test_zero_timeout }, { "aio reap", test_aio_reap }, -- cgit v1.2.3-70-g09d2