X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-19-always.c;h=7a015f28b21690ee55121a2dd3f76bbf25fca8f7;hb=e0b86f0ca416d757684e6d98532e1fadf839b830;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..7a015f28 100644 --- a/ccan/io/test/run-19-always.c +++ b/ccan/io/test/run-19-always.c @@ -6,7 +6,9 @@ #include #include -#ifndef PORT +#ifdef DEBUG_CONN +#define PORT "64019" +#else #define PORT "65019" #endif @@ -20,21 +22,25 @@ 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) { +#ifdef DEBUG_CONN + io_set_debug(conn, true); +#endif 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 +111,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 +122,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));