+}
+
+void backend_wake(const void *wait)
+{
+ unsigned int i;
+
+ for (i = 0; i < num_fds; i++) {
+ struct io_conn *c;
+
+ /* Ignore listeners */
+ if (fds[i]->listener)
+ continue;
+
+ c = (void *)fds[i];
+ if (c->plan[IO_IN].status == IO_WAITING
+ && c->plan[IO_IN].arg.u1.const_vp == wait)
+ io_do_wakeup(c, IO_IN);
+
+ if (c->plan[IO_OUT].status == IO_WAITING
+ && c->plan[IO_OUT].arg.u1.const_vp == wait)
+ io_do_wakeup(c, IO_OUT);
+ }
+}
+
+static void destroy_conn(struct io_conn *conn, bool close_fd)
+{
+ int saved_errno = errno;
+
+ if (close_fd)
+ close(conn->fd.fd);
+ del_fd(&conn->fd);
+
+ remove_from_always(&conn->plan[IO_IN]);
+ remove_from_always(&conn->plan[IO_OUT]);
+
+ /* errno saved/restored by tal_free itself. */
+ if (conn->finish) {
+ errno = saved_errno;
+ conn->finish(conn, conn->finish_arg);
+ }
+}