X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.h;fp=ccan%2Fio%2Fio.h;h=8efc0024c9d230a580bd7838de4d7ad30503e381;hp=c1d09963caa9a813bb9560763e1fd07269b8c97f;hb=17a81baf84a9c8f89603173be3169a0a2017702d;hpb=ce27b5647d5065c05db04c67e51574253275a3c2;ds=sidebyside diff --git a/ccan/io/io.h b/ccan/io/io.h index c1d09963..8efc0024 100644 --- a/ccan/io/io.h +++ b/ccan/io/io.h @@ -627,6 +627,24 @@ struct io_plan *io_close(struct io_conn *conn); */ struct io_plan *io_close_cb(struct io_conn *, void *unused); +/** + * io_close_taken_fd - close a connection, but remove the filedescriptor first. + * @conn: the connection to take the file descriptor from and close, + * + * io_close closes the file descriptor underlying the io_conn; this version does + * not. Presumably you have used io_conn_fd() on it beforehand and will take + * care of the fd yourself. + * + * Example: + * static struct io_plan *steal_fd(struct io_conn *conn, int *fd) + * { + * *fd = io_conn_fd(conn); + * printf("stealing fd %i and closing\n", *fd); + * return io_close_taken_fd(conn); + * } + */ +struct io_plan *io_close_taken_fd(struct io_conn *conn); + /** * io_loop - process fds until all closed on io_break. * @timers - timers which are waiting to go off (or NULL for none)