X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.h;h=478190f4d05b16def3f7eb481c2c8ecff334ee83;hp=bcdb11fdd0e0c1f1e9a08aac55a13e0afe888d92;hb=cdf62dce7077a9f9a818edbb67d31d033cbb73c6;hpb=12ab811533406e22b78ce8b227474f1056375ae4 diff --git a/ccan/io/io.h b/ccan/io/io.h index bcdb11fd..478190f4 100644 --- a/ccan/io/io.h +++ b/ccan/io/io.h @@ -39,7 +39,8 @@ struct io_conn *io_new_conn_(int fd, struct io_plan plan); * * @finish will be called when an I/O operation fails, or you call * io_close() on the connection. errno will be set to the value - * after the failed I/O, or at the call to io_close(). + * after the failed I/O, or at the call to io_close(). The fd + * will be closed (unless a duplex) before @finish is called. * * Example: * static void finish(struct io_conn *conn, void *unused) @@ -489,6 +490,21 @@ bool io_is_idle(const struct io_conn *conn); #define io_break(ret, plan) (io_plan_no_debug(), io_break_((ret), (plan))) struct io_plan io_break_(void *ret, struct io_plan plan); +/** + * io_never - assert if callback is called. + * + * Sometimes you want to make it clear that a callback should never happen + * (eg. for io_break). This will assert() if called. + * + * Example: + * static struct io_plan break_out(struct io_conn *conn, void *unused) + * { + * // We won't ever return from io_break + * return io_break(conn, io_never()); + * } + */ +struct io_plan io_never(void); + /* FIXME: io_recvfrom/io_sendto */ /**