From 279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 2 Nov 2024 13:57:53 -0700 Subject: NNG_OPT_RECVFD and NNG_OPT_SENDFD converted to functions. These options are removed entirely, and their functionality is now available via special functions, `nng_socket_get_send_poll_fd` and `nng_socket_get_recv_poll_fd`, making these first class methods on the socket. This eliminates a bit of wasteful code, and provides type safety for these methods. --- src/sp/protocol/reqrep0/req_test.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src/sp/protocol/reqrep0/req_test.c') diff --git a/src/sp/protocol/reqrep0/req_test.c b/src/sp/protocol/reqrep0/req_test.c index 31175cfd..61d9b347 100644 --- a/src/sp/protocol/reqrep0/req_test.c +++ b/src/sp/protocol/reqrep0/req_test.c @@ -8,6 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // +#include "nng/nng.h" #include static void @@ -517,7 +518,7 @@ test_req_poll_writeable(void) NUTS_PASS(nng_req0_open(&req)); NUTS_PASS(nng_rep0_open(&rep)); - NUTS_PASS(nng_socket_get_int(req, NNG_OPT_SENDFD, &fd)); + NUTS_PASS(nng_socket_get_send_poll_fd(req, &fd)); NUTS_TRUE(fd >= 0); // Not writable before connect. @@ -570,7 +571,7 @@ test_req_poll_contention(void) NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); NUTS_PASS(nng_msg_alloc(&msg, 0)); - NUTS_PASS(nng_socket_get_int(req, NNG_OPT_SENDFD, &fd)); + NUTS_PASS(nng_socket_get_send_poll_fd(req, &fd)); NUTS_TRUE(fd >= 0); // Not writable before connect. @@ -627,7 +628,7 @@ test_req_poll_multi_pipe(void) NUTS_PASS(nng_socket_set_int(req, NNG_OPT_SENDBUF, 1)); NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_SENDTIMEO, 1000)); - NUTS_PASS(nng_socket_get_int(req, NNG_OPT_SENDFD, &fd)); + NUTS_PASS(nng_socket_get_send_poll_fd(req, &fd)); NUTS_TRUE(fd >= 0); // Not writable before connect. @@ -655,7 +656,7 @@ test_req_poll_readable(void) NUTS_PASS(nng_req0_open(&req)); NUTS_PASS(nng_rep0_open(&rep)); - NUTS_PASS(nng_socket_get_int(req, NNG_OPT_RECVFD, &fd)); + NUTS_PASS(nng_socket_get_recv_poll_fd(req, &fd)); NUTS_TRUE(fd >= 0); // Not readable if not connected! @@ -688,21 +689,6 @@ test_req_poll_readable(void) NUTS_CLOSE(rep); } -static void -test_req_ctx_no_poll(void) -{ - int fd; - nng_socket req; - nng_ctx ctx; - - NUTS_PASS(nng_req0_open(&req)); - NUTS_PASS(nng_ctx_open(&ctx, req)); - NUTS_FAIL(nng_ctx_get_int(ctx, NNG_OPT_SENDFD, &fd), NNG_ENOTSUP); - NUTS_FAIL(nng_ctx_get_int(ctx, NNG_OPT_RECVFD, &fd), NNG_ENOTSUP); - NUTS_PASS(nng_ctx_close(ctx)); - NUTS_CLOSE(req); -} - static void test_req_ctx_send_queued(void) { @@ -1027,7 +1013,6 @@ NUTS_TESTS = { { "req context send abort", test_req_ctx_send_abort }, { "req context send twice", test_req_ctx_send_twice }, { "req context send recv abort", test_req_ctx_send_recv_abort }, - { "req context does not poll", test_req_ctx_no_poll }, { "req context recv close socket", test_req_ctx_recv_close_socket }, { "req context recv nonblock", test_req_ctx_recv_nonblock }, { "req context send nonblock", test_req_ctx_send_nonblock }, -- cgit v1.2.3-70-g09d2