X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.c;h=12df06d82cb6474fed825cd381f7f225fc6213b1;hp=36dcb81e720f448bf46665f93bb40f0692d2256c;hb=HEAD;hpb=580457bd3e4af60d5367412589d2aa1bb0289eed diff --git a/ccan/io/io.c b/ccan/io/io.c index 36dcb81e..12df06d8 100644 --- a/ccan/io/io.c +++ b/ccan/io/io.c @@ -529,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];