-#define io_write_partial(data, len, cb, arg) \
- io_debug(io_write_partial_((data), (len), \
- typesafe_cb_preargs(struct io_plan, void *, \
- (cb), (arg), \
- struct io_conn *), \
- (arg)))
-struct io_plan io_write_partial_(const void *data, size_t *len,
- struct io_plan (*cb)(struct io_conn *, void*),
- void *arg);
+#define io_write_partial(conn, data, maxlen, lenp, next, arg) \
+ io_write_partial_((conn), (data), (maxlen), (lenp), \
+ typesafe_cb_preargs(struct io_plan *, void *, \
+ (next), (arg), \
+ struct io_conn *), \
+ (arg))
+struct io_plan *io_write_partial_(struct io_conn *conn,
+ const void *data, size_t maxlen, size_t *lenp,
+ struct io_plan *(*next)(struct io_conn *,
+ void*),
+ void *arg);
+
+/**
+ * io_always - plan to immediately call next callback
+ * @conn: the connection that plan is for.
+ * @next: function to call.
+ * @arg: @next argument
+ *
+ * Sometimes it's neater to plan a callback rather than call it directly;
+ * for example, if you only need to read data for one path and not another.
+ *
+ * Example:
+ * static struct io_plan *init_conn_with_nothing(struct io_conn *conn,
+ * void *unused)
+ * {
+ * // Silly example: close on next time around loop.
+ * return io_always(conn, io_close_cb, NULL);
+ * }
+ */
+#define io_always(conn, next, arg) \
+ io_always_((conn), typesafe_cb_preargs(struct io_plan *, void *, \
+ (next), (arg), \
+ struct io_conn *), \
+ (arg))
+
+struct io_plan *io_always_(struct io_conn *conn,
+ struct io_plan *(*next)(struct io_conn *, void *),
+ void *arg);