1 /* Test previous issue: in duplex case, we wake reader reader wakes writer. */
2 #include <ccan/io/io.h>
3 /* Include the C files directly. */
4 #include <ccan/io/poll.c>
5 #include <ccan/io/io.c>
6 #include <ccan/tap/tap.h>
10 static struct io_plan *block_reading(struct io_conn *conn, void *unused)
13 return io_read(conn, buf, sizeof(buf), io_never, NULL);
16 static struct io_plan *writer_woken(struct io_conn *conn, void *unused)
18 pass("Writer woken up");
19 return io_write(conn, "1", 1, io_close_cb, NULL);
22 static struct io_plan *reader_woken(struct io_conn *conn, void *unused)
24 pass("Reader woken up");
27 return block_reading(conn, unused);
30 static struct io_plan *setup_conn(struct io_conn *conn, void *trigger)
32 return io_duplex(conn,
33 io_wait(conn, trigger, reader_woken, NULL),
34 io_out_wait(conn, conn, writer_woken, NULL));
42 ok1(socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) == 0);
44 /* We use 'fds' as pointer to wake writer. */
45 io_new_conn(NULL, fds[0], setup_conn, fds);
52 /* This exits depending on whether all tests passed */