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.c | 45 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'src/sp/protocol/reqrep0/req.c') diff --git a/src/sp/protocol/reqrep0/req.c b/src/sp/protocol/reqrep0/req.c index 416b6fb7..b8b42c26 100644 --- a/src/sp/protocol/reqrep0/req.c +++ b/src/sp/protocol/reqrep0/req.c @@ -838,30 +838,19 @@ req0_sock_get_resend_tick(void *arg, void *buf, size_t *szp, nni_opt_type t) } static int -req0_sock_get_send_fd(void *arg, void *buf, size_t *szp, nni_opt_type t) +req0_sock_get_send_fd(void *arg, int *fdp) { req0_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 int -req0_sock_get_recv_fd(void *arg, void *buf, size_t *szp, nni_opt_type t) +req0_sock_get_recv_fd(void *arg, int *fdp) { req0_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 nni_proto_pipe_ops req0_pipe_ops = { @@ -904,14 +893,6 @@ static nni_option req0_sock_options[] = { .o_get = req0_sock_get_resend_time, .o_set = req0_sock_set_resend_time, }, - { - .o_name = NNG_OPT_RECVFD, - .o_get = req0_sock_get_recv_fd, - }, - { - .o_name = NNG_OPT_SENDFD, - .o_get = req0_sock_get_send_fd, - }, { .o_name = NNG_OPT_REQ_RESENDTICK, .o_get = req0_sock_get_resend_tick, @@ -925,14 +906,16 @@ static nni_option req0_sock_options[] = { }; static nni_proto_sock_ops req0_sock_ops = { - .sock_size = sizeof(req0_sock), - .sock_init = req0_sock_init, - .sock_fini = req0_sock_fini, - .sock_open = req0_sock_open, - .sock_close = req0_sock_close, - .sock_options = req0_sock_options, - .sock_send = req0_sock_send, - .sock_recv = req0_sock_recv, + .sock_size = sizeof(req0_sock), + .sock_init = req0_sock_init, + .sock_fini = req0_sock_fini, + .sock_open = req0_sock_open, + .sock_close = req0_sock_close, + .sock_send = req0_sock_send, + .sock_recv = req0_sock_recv, + .sock_recv_poll_fd = req0_sock_get_recv_fd, + .sock_send_poll_fd = req0_sock_get_send_fd, + .sock_options = req0_sock_options, }; static nni_proto req0_proto = { -- cgit v1.2.3-70-g09d2