1 /* Licensed under LGPLv2.1+ - see LICENSE file for details */
7 * struct io_plan - a plan of what I/O to do.
8 * @pollflag: POLLIN or POLLOUT.
9 * @io: function to call when fd is available for @pollflag.
10 * @next: function to call after @io returns true.
11 * @next_arg: argument to @next.
12 * @u: scratch area for I/O.
14 * When the fd is POLLIN or POLLOUT (according to @pollflag), @io is
15 * called. If it returns -1, io_close() becomed the new plan (and errno
16 * is saved). If it returns 1, @next is called, otherwise @io is
17 * called again when @pollflag is available.
19 * You can use this to write your own io_plan functions.
23 /* Only NULL if idle. */
24 int (*io)(int fd, struct io_plan *plan);
25 /* Only NULL if closing. */
26 struct io_plan (*next)(struct io_conn *, void *arg);
66 * io_debug - routine to select connection(s) to debug.
68 * If this is set, the routine should return true if the connection is a
69 * debugging candidate. If so, the callchain for I/O operations on this
70 * connection will be linear, for easier use of a debugger.
72 extern bool (*io_debug)(struct io_conn *conn);
75 * io_plan_other - mark the next plan not being for the current connection
77 * Most routines which take a plan are about to apply it to the current
78 * connection. We (ab)use this pattern for debugging: as soon as such a
79 * plan is created, it is called, to create a linear call chain.
81 * Some routines, like io_break() and io_wake() take an io_plan, but they
82 * must not be applied immediately to the current connection, so we call this
85 #define io_plan_other() ((io_plan_for_other = true))
88 * io_plan_debug - hook for debugging a plan.
90 * After constructing a plan, call this. If the current connection is being
91 * debugged, then it will be immediately serviced with this plan.
93 void io_plan_debug(struct io_plan *plan);
94 extern bool io_plan_for_other;
96 #define io_plan_other() (void)0
97 static inline void io_plan_debug(struct io_plan *plan) { }
100 #endif /* CCAN_IO_PLAN_H */