+static void adjust_counts(enum io_state state)
+{
+ if (state == IO_NEXT)
+ num_next++;
+ else if (state == IO_FINISHED)
+ num_finished++;
+}
+
+static void update_pollevents(struct io_conn *conn)
+{
+ struct pollfd *pfd = &pollfds[conn->fd.backend_info];
+
+ if (pfd->events)
+ num_waiting--;
+
+ pfd->events = conn->plan.pollflag;
+ if (conn->duplex) {
+ int mask = conn->duplex->plan.pollflag;
+ /* You can't *both* read/write. */
+ assert(!mask || pfd->events != mask);
+ pfd->events |= mask;
+ }
+ if (pfd->events)
+ num_waiting++;
+
+ adjust_counts(conn->plan.state);
+}
+