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/pub.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/pub.c')
| -rw-r--r-- | src/sp/protocol/pubsub0/pub.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/sp/protocol/pubsub0/pub.c b/src/sp/protocol/pubsub0/pub.c index 9539b851..c40725f7 100644 --- a/src/sp/protocol/pubsub0/pub.c +++ b/src/sp/protocol/pubsub0/pub.c @@ -253,21 +253,13 @@ pub0_sock_send(void *arg, nni_aio *aio) } static int -pub0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_type t) +pub0_sock_get_sendfd(void *arg, int *fdp) { pub0_sock *sock = arg; - int fd; - int rv; - nni_mtx_lock(&sock->mtx); + // PUB sockets are *always* writable. nni_pollable_raise(&sock->sendable); - rv = nni_pollable_getfd(&sock->sendable, &fd); - nni_mtx_unlock(&sock->mtx); - - if (rv == 0) { - rv = nni_copyout_int(fd, buf, szp, t); - } - return (rv); + return (nni_pollable_getfd(&sock->sendable, fdp)); } static int @@ -321,10 +313,6 @@ static nni_proto_pipe_ops pub0_pipe_ops = { static nni_option pub0_sock_options[] = { // terminate list { - .o_name = NNG_OPT_SENDFD, - .o_get = pub0_sock_get_sendfd, - }, - { .o_name = NNG_OPT_SENDBUF, .o_get = pub0_sock_get_sendbuf, .o_set = pub0_sock_set_sendbuf, @@ -335,14 +323,15 @@ static nni_option pub0_sock_options[] = { }; static nni_proto_sock_ops pub0_sock_ops = { - .sock_size = sizeof(pub0_sock), - .sock_init = pub0_sock_init, - .sock_fini = pub0_sock_fini, - .sock_open = pub0_sock_open, - .sock_close = pub0_sock_close, - .sock_send = pub0_sock_send, - .sock_recv = pub0_sock_recv, - .sock_options = pub0_sock_options, + .sock_size = sizeof(pub0_sock), + .sock_init = pub0_sock_init, + .sock_fini = pub0_sock_fini, + .sock_open = pub0_sock_open, + .sock_close = pub0_sock_close, + .sock_send = pub0_sock_send, + .sock_recv = pub0_sock_recv, + .sock_send_poll_fd = pub0_sock_get_sendfd, + .sock_options = pub0_sock_options, }; static nni_proto pub0_proto = { |
