X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.c;fp=ccan%2Fio%2Fio.c;h=c5c9bee0daf0329f433eec930058bfd20905f96c;hp=bdcbf9e26b8f9f580fea08c2c0913d31efe9dcc7;hb=1966714494a5de39b2ee944fcc01f333c1741dbd;hpb=9f06b8f85927202c05751e43f285cbef8054052b diff --git a/ccan/io/io.c b/ccan/io/io.c index bdcbf9e2..c5c9bee0 100644 --- a/ccan/io/io.c +++ b/ccan/io/io.c @@ -61,10 +61,7 @@ static bool next_plan(struct io_conn *conn, struct io_plan *plan) if (plan == &io_conn_freed) return false; - /* It should have set a plan inside this conn (or duplex) */ - assert(plan == &conn->plan[IO_IN] - || plan == &conn->plan[IO_OUT] - || plan == &conn->plan[2]); + assert(plan == &conn->plan[plan->dir]); assert(conn->plan[IO_IN].status != IO_UNSET || conn->plan[IO_OUT].status != IO_UNSET); @@ -108,6 +105,10 @@ struct io_conn *io_new_conn_(const tal_t *ctx, int fd, /* Keep our I/O async. */ io_fd_block(fd, false); + /* So we can get back from plan -> conn later */ + conn->plan[IO_OUT].dir = IO_OUT; + conn->plan[IO_IN].dir = IO_IN; + /* We start with out doing nothing, and in doing our init. */ conn->plan[IO_OUT].status = IO_UNSET; @@ -488,7 +489,7 @@ struct io_plan *io_duplex(struct io_conn *conn, assert(conn == container_of(in_plan, struct io_conn, plan[IO_IN])); /* in_plan must be conn->plan[IO_IN], out_plan must be [IO_OUT] */ assert(out_plan == in_plan + 1); - return out_plan + 1; + return in_plan; } struct io_plan *io_halfclose(struct io_conn *conn)