+ struct pollfd *pfd = &pollfds[conn->fd.backend_info];
+
+ if (pfd->events)
+ num_waiting--;
+
+ pfd->events = 0;
+ if (conn->plan[IO_IN].status == IO_POLLING_NOTSTARTED
+ || conn->plan[IO_IN].status == IO_POLLING_STARTED)
+ pfd->events |= POLLIN;
+ if (conn->plan[IO_OUT].status == IO_POLLING_NOTSTARTED
+ || conn->plan[IO_OUT].status == IO_POLLING_STARTED)
+ pfd->events |= POLLOUT;
+
+ if (pfd->events) {
+ num_waiting++;
+ pfd->fd = conn->fd.fd;
+ } else {
+ pfd->fd = -conn->fd.fd - 1;
+ }
+}
+
+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);
+ }