X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-12-bidir.c;h=77843ae7ba0bb2951d32c6d3e56b7d64d2916eed;hb=9f06b8f85927202c05751e43f285cbef8054052b;hp=10f84295cb8650e6c8566289b9467fd9608561a6;hpb=d8ecdc8021b532fe76f001290fcd79c4fb9e1323;p=ccan diff --git a/ccan/io/test/run-12-bidir.c b/ccan/io/test/run-12-bidir.c index 10f84295..77843ae7 100644 --- a/ccan/io/test/run-12-bidir.c +++ b/ccan/io/test/run-12-bidir.c @@ -6,11 +6,7 @@ #include #include -#ifdef DEBUG_CONN -#define PORT "64012" -#else #define PORT "65012" -#endif struct data { struct io_listener *l; @@ -24,17 +20,24 @@ static void finish_ok(struct io_conn *conn, struct data *d) d->state++; } -static struct io_plan *rw_done(struct io_conn *conn, struct data *d) +static struct io_plan *r_done(struct io_conn *conn, struct data *d) { d->state++; - return io_halfclose(conn); + if (d->state == 3) + return io_close(conn); + return io_wait(conn, NULL, io_never, NULL); +} + +static struct io_plan *w_done(struct io_conn *conn, struct data *d) +{ + d->state++; + if (d->state == 3) + return io_close(conn); + return io_out_wait(conn, NULL, io_never, NULL); } 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++; @@ -44,8 +47,8 @@ static struct io_plan *init_conn(struct io_conn *conn, struct data *d) io_set_finish(conn, finish_ok, d); return io_duplex(conn, - io_read(conn, d->buf, sizeof(d->buf), rw_done, d), - io_write(conn, d->wbuf, sizeof(d->wbuf), rw_done, d)); + io_read(conn, d->buf, sizeof(d->buf), r_done, d), + io_write(conn, d->wbuf, sizeof(d->wbuf), w_done, d)); } static int make_listen_fd(const char *port, struct addrinfo **info)