X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Fio%2Ftest%2Frun-19-always.c;h=63eb34e61fb4ec443be0c88977acaea55402f52e;hb=94dd4c2bddd0dc080ad5b85465fa3f45f486967a;hp=1805f79f6619b310834f191b36161e33aba741b0;hpb=cdf62dce7077a9f9a818edbb67d31d033cbb73c6;p=ccan diff --git a/ccan/io/test/run-19-always.c b/ccan/io/test/run-19-always.c index 1805f79f..63eb34e6 100644 --- a/ccan/io/test/run-19-always.c +++ b/ccan/io/test/run-19-always.c @@ -20,21 +20,22 @@ static void finish_ok(struct io_conn *conn, struct data *d) { ok1(d->state == 1); d->state++; - io_break(d, io_never()); + io_break(d); } -static struct io_plan write_buf(struct io_conn *conn, struct data *d) +static struct io_plan *write_buf(struct io_conn *conn, struct data *d) { - return io_write(d->buf, d->bytes, io_close_cb, d); + return io_write(conn, d->buf, d->bytes, io_close_cb, d); } -static void init_conn(int fd, struct data *d) +static struct io_plan *init_conn(struct io_conn *conn, struct data *d) { ok1(d->state == 0); d->state++; + io_set_finish(conn, finish_ok, d); + /* Empty read should run immediately... */ - io_set_finish(io_new_conn(fd, io_read(NULL, 0, write_buf, d)), - finish_ok, d); + return io_read(conn, NULL, 0, write_buf, d); } static int make_listen_fd(const char *port, struct addrinfo **info) @@ -105,7 +106,7 @@ int main(void) memset(d->buf, 'a', d->bytes); fd = make_listen_fd(PORT, &addrinfo); ok1(fd >= 0); - l = io_new_listener(fd, init_conn, d); + l = io_new_listener(NULL, fd, init_conn, d); ok1(l); fflush(stdout); if (!fork()) { @@ -116,7 +117,7 @@ int main(void) free(d); exit(0); } - ok1(io_loop() == d); + ok1(io_loop(NULL, NULL) == d); ok1(d->state == 2); ok1(wait(&status));