X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-05-write.c;h=3b0cc72432a30f840e9e0f58f28712dce897f12d;hb=96dcdfbf1a400f7cb43cf3f0761f52fd6de9ff65;hp=bcbc9cad119e3b82ccc0eb3e12f1838fc734792a;hpb=0f16a4197c94bfa84dad56d0cb9a9c20438d0a45;p=ccan diff --git a/ccan/io/test/run-05-write.c b/ccan/io/test/run-05-write.c index bcbc9cad..3b0cc724 100644 --- a/ccan/io/test/run-05-write.c +++ b/ccan/io/test/run-05-write.c @@ -6,9 +6,7 @@ #include #include -#ifndef PORT #define PORT "65005" -#endif struct data { int state; @@ -20,15 +18,15 @@ static void finish_ok(struct io_conn *conn, struct data *d) { ok1(d->state == 1); d->state++; - io_break(d, io_idle()); + io_break(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(io_new_conn(fd, io_write(d->buf, d->bytes, io_close, d)), - finish_ok, d); + io_set_finish(conn, finish_ok, d); + return io_write(conn, d->buf, d->bytes, io_close_cb, d); } static int make_listen_fd(const char *port, struct addrinfo **info) @@ -99,7 +97,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()) { @@ -110,7 +108,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));