rust-lang/rust — pull request #15704 by alexcrichton (2014-07-16 05:57:18+00:00)
Title: Implement {Tcp,Unix}Acceptor::{clone, close_accept}

If a task is spinning in an accept loop, there is currently no method of gracefully shutting it down. This PR introduces a way to do so by cloning the acceptor an implementing a close_accept method to unblocking any pending acceptor.

As with other I/O methods like this, it is `#[experimental]` from the start and sadly carries with it a good deal of code to support it. Much of the complication is from the fact that you can now concurrently accept on the same socket.

I tried to add a good deal of tests for this change, but another set of eyes is always appreciated!