]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/poll.c
io: change io_idle() to io_wait()
[ccan] / ccan / io / poll.c
index e3f595c9884c0d2fcea42d598ca3321d067069a8..8ba376a549aa47ee4be29af3345c034dfdfbf481 100644 (file)
@@ -167,6 +167,34 @@ void backend_plan_changed(struct io_conn *conn)
                some_always = true;
 }
 
+void backend_wait_changed(const void *wait)
+{
+       unsigned int i;
+
+       for (i = 0; i < num_fds; i++) {
+               struct io_conn *c, *duplex;
+
+               /* Ignore listeners */
+               if (fds[i]->listener)
+                       continue;
+               c = (void *)fds[i];
+               for (duplex = c->duplex; c; c = duplex, duplex = NULL) {
+                       /* Ignore closing. */
+                       if (!c->plan.next)
+                               continue;
+                       /* Not idle? */
+                       if (c->plan.io)
+                               continue;
+                       /* Waiting on something else? */
+                       if (c->plan.u1.const_vp != wait)
+                               continue;
+                       /* Make it do the next thing. */
+                       c->plan = io_always_(c->plan.next, c->plan.next_arg);
+                       backend_plan_changed(c);
+               }
+       }
+}
+
 bool add_conn(struct io_conn *c)
 {
        if (!add_fd(&c->fd, c->plan.pollflag & (POLLIN|POLLOUT)))