X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-06-idle.c;h=314293a5f0f2b5d6a145c8b38359056bf4a6bc0a;hp=19d0f8b1a682ddf33f0d9331cb8be8a41d77cfcd;hb=737705f0c2ec60ea5b51ca55299488d86db37b5d;hpb=625bae8f5720d3ad3253ea9b26ad68abcd81bde5 diff --git a/ccan/io/test/run-06-idle.c b/ccan/io/test/run-06-idle.c index 19d0f8b1..314293a5 100644 --- a/ccan/io/test/run-06-idle.c +++ b/ccan/io/test/run-06-idle.c @@ -20,7 +20,7 @@ static struct io_plan plan_read(struct io_conn *conn, struct data *d) { ok1(d->state == 2 || d->state == 3); d->state++; - return io_read(conn, d->buf, sizeof(d->buf), io_close, d); + return io_read(d->buf, sizeof(d->buf), io_close, d); } static struct io_plan start_waker(struct io_conn *conn, struct data *d) @@ -51,14 +51,20 @@ static struct io_plan start_idle(struct io_conn *conn, struct data *d) ok1(fd >= 0); ok1(io_new_conn(fd, start_waker, finish_waker, d)); - return io_idle(conn); + return io_idle(); } static void finish_idle(struct io_conn *conn, struct data *d) { ok1(d->state == 4); d->state++; - io_break(conn, d, NULL, NULL); + io_break(d, NULL, NULL); +} + +static void init_conn(int fd, struct data *d) +{ + if (!io_new_conn(fd, start_idle, finish_idle, d)) + abort(); } static int make_listen_fd(const char *port, struct addrinfo **info) @@ -105,7 +111,7 @@ int main(void) d->state = 0; fd = make_listen_fd("65006", &addrinfo); ok1(fd >= 0); - l = io_new_listener(fd, start_idle, finish_idle, d); + l = io_new_listener(fd, init_conn, d); ok1(l); fflush(stdout); if (!fork()) {