+#ifdef DEBUG
+bool io_plan_for_other;
+struct io_conn *current;
+bool (*io_debug)(struct io_conn *conn);
+bool io_debug_wakeup;
+
+void io_plan_debug(struct io_plan *plan)
+{
+ if (io_plan_for_other) {
+ io_plan_for_other = false;
+ return;
+ }
+
+ if (!io_debug || !current)
+ return;
+
+ if (!io_debug(current) && !io_debug_wakeup)
+ return;
+
+ io_debug_wakeup = false;
+ current->plan = *plan;
+ backend_plan_changed(current);
+
+ /* Call back into the loop immediately. */
+ io_loop_return = io_loop();
+}
+
+static void debug_io_wake(struct io_conn *conn)
+{
+ /* We want linear if we wake a debugged connection, too. */
+ if (io_debug && io_debug(conn))
+ io_debug_wakeup = true;
+}
+#else
+static void debug_io_wake(struct io_conn *conn)
+{
+}
+#endif
+