+
+ io_new_conn(l->ctx, fd, l->init, l->arg);
+}
+
+/* Return pointer to exclusive flag for this plan. */
+static bool *exclusive(struct io_plan *plan)
+{
+ struct io_conn *conn;
+
+ conn = container_of(plan, struct io_conn, plan[plan->dir]);
+ return &conn->fd.exclusive[plan->dir];
+}
+
+/* For simplicity, we do one always at a time */
+static bool handle_always(void)
+{
+ /* Backwards is simple easier to remove entries */
+ for (int i = num_always - 1; i >= 0; i--) {
+ struct io_plan *plan = always[i];
+
+ if (num_exclusive && !*exclusive(plan))
+ continue;
+ /* Remove first: it might re-add */
+ if (i != num_always-1)
+ always[i] = always[num_always-1];
+ num_always--;
+ io_do_always(plan);
+ return true;
+ }
+
+ return false;
+}
+
+bool backend_set_exclusive(struct io_plan *plan, bool excl)
+{
+ bool *excl_ptr = exclusive(plan);
+
+ if (excl != *excl_ptr) {
+ *excl_ptr = excl;
+ if (!excl)
+ num_exclusive--;
+ else
+ num_exclusive++;
+ }
+
+ return num_exclusive != 0;
+}
+
+/* FIXME: We could do this once at set_exclusive time, and catch everywhere
+ * else that we manipulate events. */
+static void exclude_pollfds(void)
+{
+ if (num_exclusive == 0)