struct io_plan {
int pollflag;
/* Only NULL if idle. */
- bool (*io)(int fd, struct io_plan *plan);
+ int (*io)(int fd, struct io_plan *plan);
/* Only NULL if closing. */
struct io_plan (*next)(struct io_conn *, void *arg);
void *next_arg;
const char *buf;
size_t *lenp;
} writepart;
+ struct {
+ int saved_errno;
+ } close;
struct {
void *p;
size_t len;
* @arg: the argument to @finish.
*
* @finish will be called when an I/O operation fails, or you call
- * io_close() on the connection.
+ * io_close() on the connection. errno will be set to the value
+ * after the failed I/O, or at the call to io_close().
*/
#define io_set_finish(conn, finish, arg) \
io_set_finish_((conn), \
/* FIXME: io_recvfrom/io_sendto */
/**
- * io_close - terminate a connection.
- * @conn: any connection.
+ * io_close - plan to close a connection.
*
- * The schedules a connection to be closed. It can be done on any
- * connection, whether it has I/O queued or not (though that I/O may
- * be performed first).
+ * On return to io_loop, the connection will be closed.
+ */
+struct io_plan io_close(void);
+
+/**
+ * io_close_cb - helper callback to close a connection.
+ * @conn: the connection.
*
- * It's common to 'return io_close(...)' from a @next function, but
- * io_close can also be used as an argument to io_next().
+ * This schedules a connection to be closed; designed to be used as
+ * a callback function.
*/
-struct io_plan io_close(struct io_conn *, void *unused);
+struct io_plan io_close_cb(struct io_conn *, void *unused);
/**
* io_loop - process fds until all closed on io_break.