aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/pipeline0/pull.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-02 13:57:53 -0700
committerGarrett D'Amore <garrett@damore.org>2024-11-02 14:47:50 -0700
commit279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 (patch)
treeb451ac7f845062674d6ab45eb5d530628d3ff47c /src/sp/protocol/pipeline0/pull.c
parent9b27984d0e2da430b78a975e59f55c96de5f6056 (diff)
downloadnng-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/pipeline0/pull.c')
-rw-r--r--src/sp/protocol/pipeline0/pull.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/sp/protocol/pipeline0/pull.c b/src/sp/protocol/pipeline0/pull.c
index 40dd514c..bfd8f6ea 100644
--- a/src/sp/protocol/pipeline0/pull.c
+++ b/src/sp/protocol/pipeline0/pull.c
@@ -253,23 +253,14 @@ pull0_sock_recv(void *arg, nni_aio *aio)
}
static int
-pull0_sock_get_recv_fd(void *arg, void *buf, size_t *szp, nni_opt_type t)
+pull0_sock_get_recv_fd(void *arg, int *fdp)
{
pull0_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_option pull0_sock_options[] = {
- {
- .o_name = NNG_OPT_RECVFD,
- .o_get = pull0_sock_get_recv_fd,
- },
// terminate list
{
.o_name = NULL,
@@ -286,14 +277,15 @@ static nni_proto_pipe_ops pull0_pipe_ops = {
};
static nni_proto_sock_ops pull0_sock_ops = {
- .sock_size = sizeof(pull0_sock),
- .sock_init = pull0_sock_init,
- .sock_fini = pull0_sock_fini,
- .sock_open = pull0_sock_open,
- .sock_close = pull0_sock_close,
- .sock_send = pull0_sock_send,
- .sock_recv = pull0_sock_recv,
- .sock_options = pull0_sock_options,
+ .sock_size = sizeof(pull0_sock),
+ .sock_init = pull0_sock_init,
+ .sock_fini = pull0_sock_fini,
+ .sock_open = pull0_sock_open,
+ .sock_close = pull0_sock_close,
+ .sock_send = pull0_sock_send,
+ .sock_recv = pull0_sock_recv,
+ .sock_recv_poll_fd = pull0_sock_get_recv_fd,
+ .sock_options = pull0_sock_options,
};
static nni_proto pull0_proto = {