1 /* GNU LGPL version 2 (or later) - see LICENSE file for details */
2 #include <ccan/io/fdpass/fdpass.h>
3 #include <ccan/fdpass/fdpass.h>
4 #include <ccan/io/io_plan.h>
7 static int do_fd_send(int fd, struct io_plan_arg *arg)
9 if (!fdpass_send(fd, arg->u1.s)) {
10 /* In case ccan/io ever gets smart with non-blocking. */
11 if (errno == EAGAIN || errno == EWOULDBLOCK)
18 struct io_plan *io_send_fd_(struct io_conn *conn,
20 struct io_plan *(*next)(struct io_conn *, void *),
23 struct io_plan_arg *arg = io_plan_arg(conn, IO_OUT);
27 return io_set_plan(conn, IO_OUT, do_fd_send, next, next_arg);
30 static int do_fd_recv(int fd, struct io_plan_arg *arg)
32 int fdin = fdpass_recv(fd);
35 /* In case ccan/io ever gets smart with non-blocking. */
36 if (errno == EAGAIN || errno == EWOULDBLOCK)
40 *(int *)arg->u1.vp = fdin;
44 struct io_plan *io_recv_fd_(struct io_conn *conn,
46 struct io_plan *(*next)(struct io_conn *, void *),
49 struct io_plan_arg *arg = io_plan_arg(conn, IO_IN);
53 return io_set_plan(conn, IO_IN, do_fd_recv, next, next_arg);