-struct io_conn *io_new_conn_(int fd,
- struct io_op *(*start)(struct io_conn *, void *),
- void (*finish)(struct io_conn *, void *),
+static struct io_plan *io_never_called(struct io_conn *conn, void *arg)
+{
+ abort();
+}
+
+static void next_plan(struct io_conn *conn, struct io_plan *plan)
+{
+ struct io_plan *(*next)(struct io_conn *, void *arg);
+
+ next = plan->next;
+
+ plan->status = IO_UNSET;
+ plan->io = NULL;
+ plan->next = io_never_called;
+
+ plan = next(conn, plan->next_arg);
+
+ /* It should have set a plan inside this conn. */
+ assert(plan == &conn->plan[IO_IN]
+ || plan == &conn->plan[IO_OUT]);
+ assert(conn->plan[IO_IN].status != IO_UNSET
+ || conn->plan[IO_OUT].status != IO_UNSET);
+
+ backend_new_plan(conn);
+}
+
+struct io_conn *io_new_conn_(const tal_t *ctx, int fd,
+ struct io_plan *(*init)(struct io_conn *, void *),