diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-02 13:57:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-02 14:47:50 -0700 |
| commit | 279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 (patch) | |
| tree | b451ac7f845062674d6ab45eb5d530628d3ff47c /src/sp/protocol/pair0/pair.c | |
| parent | 9b27984d0e2da430b78a975e59f55c96de5f6056 (diff) | |
| download | nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.gz nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.bz2 nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.zip | |
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.
Diffstat (limited to 'src/sp/protocol/pair0/pair.c')
| -rw-r--r-- | src/sp/protocol/pair0/pair.c | 44 |
1 files changed, 14 insertions, 30 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) |
