summaryrefslogtreecommitdiff
path: root/cli/tokio_util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tokio_util.rs')
-rw-r--r--cli/tokio_util.rs21
1 files changed, 2 insertions, 19 deletions
diff --git a/cli/tokio_util.rs b/cli/tokio_util.rs
index a57cbbd2e..e1f8587c3 100644
--- a/cli/tokio_util.rs
+++ b/cli/tokio_util.rs
@@ -78,31 +78,14 @@ pub fn accept(r: Resource) -> Accept {
pub struct Accept {
state: AcceptState,
}
+
impl Future for Accept {
type Item = (TcpStream, SocketAddr);
type Error = io::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let (stream, addr) = match self.state {
- // Similar to try_ready!, but also track/untrack accept task
- // in TcpListener resource.
- // In this way, when the listener is closed, the task can be
- // notified to error out (instead of stuck forever).
- AcceptState::Pending(ref mut r) => match r.poll_accept() {
- Ok(futures::prelude::Async::Ready(t)) => {
- r.untrack_task();
- t
- }
- Ok(futures::prelude::Async::NotReady) => {
- // Would error out if another accept task is being tracked.
- r.track_task()?;
- return Ok(futures::prelude::Async::NotReady);
- }
- Err(e) => {
- r.untrack_task();
- return Err(From::from(e));
- }
- },
+ AcceptState::Pending(ref mut r) => try_ready!(r.poll_accept()),
AcceptState::Empty => panic!("poll Accept after it's done"),
};