Skip to content

Commit

Permalink
fix(conn): don't double shutdown in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Dec 15, 2017
1 parent 9af18f3 commit 7d3abfb
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/proto/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
Ok(Async::NotReady) => unreachable!("dispatch not ready when conn is"),
Err(()) => {
trace!("dispatch no longer receiving messages");
self.is_closing = true;
self.close();
return Ok(Async::Ready(()));
}
}
Expand Down Expand Up @@ -180,9 +180,7 @@ where
self.conn.write_head(head, body.is_some());
self.body_rx = body;
} else {
self.is_closing = true;
//self.conn.close_read();
//self.conn.close_write();
self.close();
return Ok(Async::Ready(()));
}
} else if self.conn.has_queued_body() {
Expand Down Expand Up @@ -218,17 +216,17 @@ where
})
}

fn poll_close(&mut self) -> Poll<(), ::Error> {
debug_assert!(self.is_closing);

try_ready!(self.conn.close_and_shutdown());
fn close(&mut self) {
self.is_closing = true;
self.conn.close_read();
self.conn.close_write();
self.is_closing = false;
Ok(Async::Ready(()))
}

fn is_done(&self) -> bool {
if self.is_closing {
return true;
}

let read_done = self.conn.is_read_closed();

if !T::should_read_first() && read_done {
Expand Down Expand Up @@ -262,10 +260,6 @@ where
self.poll_write()?;
self.poll_flush()?;

if self.is_closing {
self.poll_close()?;
}

if self.is_done() {
try_ready!(self.conn.shutdown());
trace!("Dispatch::poll done");
Expand Down

0 comments on commit 7d3abfb

Please sign in to comment.