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)
20 struct io_plan *io_send_fd_(struct io_conn *conn,
23 struct io_plan *(*next)(struct io_conn *, void *),
26 struct io_plan_arg *arg = io_plan_arg(conn, IO_OUT);
31 return io_set_plan(conn, IO_OUT, do_fd_send, next, next_arg);
34 static int do_fd_recv(int fd, struct io_plan_arg *arg)
36 int fdin = fdpass_recv(fd);
39 /* In case ccan/io ever gets smart with non-blocking. */
40 if (errno == EAGAIN || errno == EWOULDBLOCK)
44 *(int *)arg->u1.vp = fdin;
48 struct io_plan *io_recv_fd_(struct io_conn *conn,
50 struct io_plan *(*next)(struct io_conn *, void *),
53 struct io_plan_arg *arg = io_plan_arg(conn, IO_IN);
57 return io_set_plan(conn, IO_IN, do_fd_recv, next, next_arg);