diff options
Diffstat (limited to 'src/sp/protocol/pair0')
| -rw-r--r-- | src/sp/protocol/pair0/pair.c | 44 | ||||
| -rw-r--r-- | src/sp/protocol/pair0/pair0_test.c | 7 |
2 files changed, 18 insertions, 33 deletions
diff --git a/src/sp/protocol/pair0/pair.c b/src/sp/protocol/pair0/pair.c index 558a9e3b..254c2810 100644 --- a/src/sp/protocol/pair0/pair.c +++ b/src/sp/protocol/pair0/pair.c @@ -513,41 +513,23 @@ pair0_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) } static int -pair0_sock_get_recv_fd(void *arg, void *buf, size_t *szp, nni_opt_type t) +pair0_sock_get_recv_fd(void *arg, int *fdp) { pair0_sock *s = arg; - int rv; - int fd; - if ((rv = nni_pollable_getfd(&s->readable, &fd)) != 0) { - return (rv); - } - return (nni_copyout_int(fd, buf, szp, t)); + return (nni_pollable_getfd(&s->readable, fdp)); } static int -pair0_sock_get_send_fd(void *arg, void *buf, size_t *szp, nni_opt_type t) +pair0_sock_get_send_fd(void *arg, int *fdp) { pair0_sock *s = arg; - int rv; - int fd; - if ((rv = nni_pollable_getfd(&s->writable, &fd)) != 0) { - return (rv); - } - return (nni_copyout_int(fd, buf, szp, t)); + return (nni_pollable_getfd(&s->writable, fdp)); } static nni_option pair0_sock_options[] = { { - .o_name = NNG_OPT_RECVFD, - .o_get = pair0_sock_get_recv_fd, - }, - { - .o_name = NNG_OPT_SENDFD, - .o_get = pair0_sock_get_send_fd, - }, - { .o_name = NNG_OPT_SENDBUF, .o_get = pair0_get_send_buf_len, .o_set = pair0_set_send_buf_len, @@ -573,14 +555,16 @@ static nni_proto_pipe_ops pair0_pipe_ops = { }; static nni_proto_sock_ops pair0_sock_ops = { - .sock_size = sizeof(pair0_sock), - .sock_init = pair0_sock_init, - .sock_fini = pair0_sock_fini, - .sock_open = pair0_sock_open, - .sock_close = pair0_sock_close, - .sock_send = pair0_sock_send, - .sock_recv = pair0_sock_recv, - .sock_options = pair0_sock_options, + .sock_size = sizeof(pair0_sock), + .sock_init = pair0_sock_init, + .sock_fini = pair0_sock_fini, + .sock_open = pair0_sock_open, + .sock_close = pair0_sock_close, + .sock_send = pair0_sock_send, + .sock_recv = pair0_sock_recv, + .sock_recv_poll_fd = pair0_sock_get_recv_fd, + .sock_send_poll_fd = pair0_sock_get_send_fd, + .sock_options = pair0_sock_options, }; // Legacy protocol (v0) diff --git a/src/sp/protocol/pair0/pair0_test.c b/src/sp/protocol/pair0/pair0_test.c index 83d72c0c..e2196479 100644 --- a/src/sp/protocol/pair0/pair0_test.c +++ b/src/sp/protocol/pair0/pair0_test.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -8,6 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // +#include "nng/nng.h" #include <nuts.h> #define SECOND 1000 @@ -340,7 +341,7 @@ test_pair0_poll_readable(void) NUTS_PASS(nng_pair0_open(&s2)); NUTS_PASS(nng_socket_set_ms(s1, NNG_OPT_RECVTIMEO, 1000)); NUTS_PASS(nng_socket_set_ms(s2, NNG_OPT_SENDTIMEO, 1000)); - NUTS_PASS(nng_socket_get_int(s1, NNG_OPT_RECVFD, &fd)); + NUTS_PASS(nng_socket_get_recv_poll_fd(s1, &fd)); NUTS_TRUE(fd >= 0); // Not readable if not connected! @@ -386,7 +387,7 @@ test_pair0_poll_writable(void) NUTS_PASS(nng_pair0_open(&s2)); NUTS_PASS(nng_socket_set_ms(s1, NNG_OPT_RECVTIMEO, 1000)); NUTS_PASS(nng_socket_set_ms(s2, NNG_OPT_SENDTIMEO, 1000)); - NUTS_PASS(nng_socket_get_int(s1, NNG_OPT_SENDFD, &fd)); + NUTS_PASS(nng_socket_get_send_poll_fd(s1, &fd)); NUTS_TRUE(fd >= 0); // Not writable if not connected! |
