aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/reqrep0/xrep_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-26 10:20:33 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-26 10:52:17 -0800
commit06ebeefb102b223ff77dd47e16b64bd9575f7c34 (patch)
treecf5d70cadfd2f7261bb5fd6443d2c449d1c1e812 /src/sp/protocol/reqrep0/xrep_test.c
parentd02a320cffc82de8437c28869355a403069b3b21 (diff)
downloadnng-06ebeefb102b223ff77dd47e16b64bd9575f7c34.tar.gz
nng-06ebeefb102b223ff77dd47e16b64bd9575f7c34.tar.bz2
nng-06ebeefb102b223ff77dd47e16b64bd9575f7c34.zip
aio: introduce NNG_ESTOPPED
This error code results when an AIO is stopped permanently, as a result of nni_aio_close or nni_aio_stop. The associated AIO object cannot be used again. This discrimantes against a file being closed, or a temporary cancellation which might allow the aio to be reused. Consumers must check for this error status in their callbacks, and not resubmit an operation that failed with this error. Doing so, will result in an infinite loop of submit / errors.
Diffstat (limited to 'src/sp/protocol/reqrep0/xrep_test.c')
-rw-r--r--src/sp/protocol/reqrep0/xrep_test.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sp/protocol/reqrep0/xrep_test.c b/src/sp/protocol/reqrep0/xrep_test.c
index d5110469..068d64a7 100644
--- a/src/sp/protocol/reqrep0/xrep_test.c
+++ b/src/sp/protocol/reqrep0/xrep_test.c
@@ -262,6 +262,23 @@ test_xrep_recv_aio_stopped(void)
nng_aio_stop(aio);
nng_recv_aio(rep, aio);
nng_aio_wait(aio);
+ NUTS_FAIL(nng_aio_result(aio), NNG_ESTOPPED);
+ NUTS_CLOSE(rep);
+ nng_aio_free(aio);
+}
+
+static void
+test_xrep_recv_aio_canceled(void)
+{
+ nng_socket rep;
+ nng_aio *aio;
+
+ NUTS_PASS(nng_rep0_open_raw(&rep));
+ NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
+
+ nng_recv_aio(rep, aio);
+ nng_aio_cancel(aio);
+ nng_aio_wait(aio);
NUTS_FAIL(nng_aio_result(aio), NNG_ECANCELED);
NUTS_CLOSE(rep);
nng_aio_free(aio);
@@ -415,6 +432,7 @@ NUTS_TESTS = {
{ "xrep close pipe during send", test_xrep_close_pipe_during_send },
{ "xrep close during recv", test_xrep_close_during_recv },
{ "xrep recv aio stopped", test_xrep_recv_aio_stopped },
+ { "xrep recv aio canceled", test_xrep_recv_aio_canceled },
{ "xrep send no header", test_xrep_send_no_header },
{ "xrep recv garbage", test_xrep_recv_garbage },
{ "xrep ttl option", test_xrep_ttl_option },