aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/bus0
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/bus0
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/bus0')
-rw-r--r--src/sp/protocol/bus0/bus_test.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/sp/protocol/bus0/bus_test.c b/src/sp/protocol/bus0/bus_test.c
index a6b04df9..c9952d81 100644
--- a/src/sp/protocol/bus0/bus_test.c
+++ b/src/sp/protocol/bus0/bus_test.c
@@ -189,11 +189,32 @@ test_bus_aio_stopped(void)
nng_recv_aio(s1, aio);
nng_aio_wait(aio);
- NUTS_FAIL(nng_aio_result(aio), NNG_ECANCELED);
+ NUTS_FAIL(nng_aio_result(aio), NNG_ESTOPPED);
nng_aio_set_msg(aio, msg);
nng_send_aio(s1, aio);
nng_aio_wait(aio);
+ NUTS_FAIL(nng_aio_result(aio), NNG_ESTOPPED);
+
+ nng_aio_free(aio);
+ nng_msg_free(msg);
+ NUTS_CLOSE(s1);
+}
+
+static void
+test_bus_aio_canceled(void)
+{
+ nng_socket s1;
+ nng_aio *aio;
+ nng_msg *msg;
+
+ NUTS_PASS(nng_bus0_open(&s1));
+ NUTS_PASS(nng_msg_alloc(&msg, 0));
+ NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
+
+ nng_recv_aio(s1, aio);
+ nng_aio_cancel(aio);
+ nng_aio_wait(aio);
NUTS_FAIL(nng_aio_result(aio), NNG_ECANCELED);
nng_aio_free(aio);
@@ -393,6 +414,7 @@ TEST_LIST = {
{ "bus recv cancel", test_bus_recv_cancel },
{ "bus close recv abort", test_bus_close_recv_abort },
{ "bus aio stopped", test_bus_aio_stopped },
+ { "bus aio canceled", test_bus_aio_canceled },
{ "bus recv buf option", test_bus_recv_buf_option },
{ "bus send buf option", test_bus_send_buf_option },
{ "bus cooked", test_bus_cooked },