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/pubsub0/sub.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/pubsub0/sub.c')
| -rw-r--r-- | src/sp/protocol/pubsub0/sub.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c index ee911153..5d6a2a05 100644 --- a/src/sp/protocol/pubsub0/sub.c +++ b/src/sp/protocol/pubsub0/sub.c @@ -615,16 +615,11 @@ sub0_sock_recv(void *arg, nni_aio *aio) } static int -sub0_sock_get_recv_fd(void *arg, void *buf, size_t *szp, nni_opt_type t) +sub0_sock_get_recv_fd(void *arg, int *fdp) { sub0_sock *sock = arg; - int rv; - int fd; - if ((rv = nni_pollable_getfd(&sock->readable, &fd)) != 0) { - return (rv); - } - return (nni_copyout_int(fd, buf, szp, t)); + return (nni_pollable_getfd(&sock->readable, fdp)); } static int @@ -699,10 +694,6 @@ static nni_option sub0_sock_options[] = { .o_set = sub0_sock_unsubscribe, }, { - .o_name = NNG_OPT_RECVFD, - .o_get = sub0_sock_get_recv_fd, - }, - { .o_name = NNG_OPT_RECVBUF, .o_get = sub0_sock_get_recv_buf_len, .o_set = sub0_sock_set_recv_buf_len, @@ -719,14 +710,15 @@ static nni_option sub0_sock_options[] = { }; static nni_proto_sock_ops sub0_sock_ops = { - .sock_size = sizeof(sub0_sock), - .sock_init = sub0_sock_init, - .sock_fini = sub0_sock_fini, - .sock_open = sub0_sock_open, - .sock_close = sub0_sock_close, - .sock_send = sub0_sock_send, - .sock_recv = sub0_sock_recv, - .sock_options = sub0_sock_options, + .sock_size = sizeof(sub0_sock), + .sock_init = sub0_sock_init, + .sock_fini = sub0_sock_fini, + .sock_open = sub0_sock_open, + .sock_close = sub0_sock_close, + .sock_send = sub0_sock_send, + .sock_recv = sub0_sock_recv, + .sock_recv_poll_fd = sub0_sock_get_recv_fd, + .sock_options = sub0_sock_options, }; static nni_proto sub0_proto = { |
