X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-01-start-finish.c;h=b5114abeafcceabe3b26d88581336e63b89ee582;hp=7c6ae4155f3b052202d6dfb55f02c0b77f28479d;hb=57d9d1be33905691ec756b14b066181ca6850ced;hpb=625bae8f5720d3ad3253ea9b26ad68abcd81bde5 diff --git a/ccan/io/test/run-01-start-finish.c b/ccan/io/test/run-01-start-finish.c index 7c6ae415..b5114abe 100644 --- a/ccan/io/test/run-01-start-finish.c +++ b/ccan/io/test/run-01-start-finish.c @@ -6,18 +6,19 @@ #include #include -static struct io_plan start_ok(struct io_conn *conn, int *state) +static void finish_ok(struct io_conn *conn, int *state) { - ok1(*state == 0); + ok1(*state == 1); (*state)++; - return io_close(conn, NULL); + io_break(state + 1, io_idle()); } -static void finish_ok(struct io_conn *conn, int *state) +static void init_conn(int fd, int *state) { - ok1(*state == 1); + ok1(*state == 0); (*state)++; - io_break(conn, state + 1, NULL, NULL); + if (!io_new_conn(fd, io_close(NULL, NULL), finish_ok, state)) + abort(); } static int make_listen_fd(const char *port, struct addrinfo **info) @@ -63,7 +64,7 @@ int main(void) plan_tests(9); fd = make_listen_fd("65001", &addrinfo); ok1(fd >= 0); - l = io_new_listener(fd, start_ok, finish_ok, &state); + l = io_new_listener(fd, init_conn, &state); ok1(l); fflush(stdout); if (!fork()) {