X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.c;h=12df06d82cb6474fed825cd381f7f225fc6213b1;hp=7ebd5a202d7899f356ed1963eb3c6f463ee986e2;hb=HEAD;hpb=a5881c0deb210f56c2095366ae6cdabd5230d68d diff --git a/ccan/io/io.c b/ccan/io/io.c index 7ebd5a20..12df06d8 100644 --- a/ccan/io/io.c +++ b/ccan/io/io.c @@ -119,6 +119,16 @@ struct io_conn *io_new_conn_(const tal_t *ctx, int fd, return conn; } +bool io_conn_exclusive(struct io_conn *conn, bool exclusive) +{ + return backend_set_exclusive(&conn->plan[IO_IN], exclusive); +} + +bool io_conn_out_exclusive(struct io_conn *conn, bool exclusive) +{ + return backend_set_exclusive(&conn->plan[IO_OUT], exclusive); +} + void io_set_finish_(struct io_conn *conn, void (*finish)(struct io_conn *, void *), void *arg) @@ -519,6 +529,18 @@ bool io_plan_out_started(const struct io_conn *conn) return conn->plan[IO_OUT].status == IO_POLLING_STARTED; } +/* Despite being a TCP expert, I missed the full extent of this + * problem. The legendary ZmnSCPxj implemented it (with the URL + * pointing to the explanation), and I imitate that here. */ +struct io_plan *io_sock_shutdown(struct io_conn *conn) +{ + if (shutdown(io_conn_fd(conn), SHUT_WR) != 0) + return io_close(conn); + + /* And leave unset .*/ + return &conn->plan[IO_IN]; +} + bool io_flush_sync(struct io_conn *conn) { struct io_plan *plan = &conn->plan[IO_OUT];