]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-01-start-finish.c
ccan/io: initialize connection with an explicit I/O plan.
[ccan] / ccan / io / test / run-01-start-finish.c
index 53c07f24b4a07b0267953966b2a37af6242ea158..b5114abeafcceabe3b26d88581336e63b89ee582 100644 (file)
@@ -6,23 +6,18 @@
 #include <sys/wait.h>
 #include <stdio.h>
 
-static struct io_plan start_ok(struct io_conn *conn, int *state)
-{
-       ok1(*state == 0);
-       (*state)++;
-       return io_close(conn, NULL);
-}
-
 static void finish_ok(struct io_conn *conn, int *state)
 {
        ok1(*state == 1);
        (*state)++;
-       io_break(state + 1, NULL, NULL);
+       io_break(state + 1, io_idle());
 }
 
 static void init_conn(int fd, int *state)
 {
-       if (!io_new_conn(fd, start_ok, finish_ok, state))
+       ok1(*state == 0);
+       (*state)++;
+       if (!io_new_conn(fd, io_close(NULL, NULL), finish_ok, state))
                abort();
 }