X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-19-always.c;h=af190a4d025efeaa085ff9fd0c4711352a14f0f8;hb=96dcdfbf1a400f7cb43cf3f0761f52fd6de9ff65;hp=e6413fc916fec4434a8bc775a641fa0406a9c420;hpb=12ab811533406e22b78ce8b227474f1056375ae4;p=ccan diff --git a/ccan/io/test/run-19-always.c b/ccan/io/test/run-19-always.c index e6413fc9..af190a4d 100644 --- a/ccan/io/test/run-19-always.c +++ b/ccan/io/test/run-19-always.c @@ -6,9 +6,7 @@ #include #include -#ifndef PORT #define PORT "65019" -#endif struct data { int state; @@ -20,21 +18,22 @@ 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 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 +104,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 +115,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));