aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/aio_test.c24
-rw-r--r--src/nng.c6
2 files changed, 29 insertions, 1 deletions
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. <info@staysail.tech>
+// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -191,6 +191,27 @@ test_explicit_timeout(void)
}
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)
{
nng_socket s;
@@ -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 },
diff --git a/src/nng.c b/src/nng.c
index 79259568..ce75d832 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -1919,6 +1919,12 @@ nng_aio_set_timeout(nng_aio *aio, nni_duration when)
nni_aio_set_timeout(aio, when);
}
+void
+nng_aio_set_expire(nng_aio *aio, nng_time when)
+{
+ nni_aio_set_expire(aio, when);
+}
+
int
nng_aio_set_iov(nng_aio *aio, unsigned niov, const nng_iov *iov)
{