fix(conn): don't double shutdown in some cases
This commit is contained in:
@@ -77,7 +77,7 @@ where
|
|||||||
Ok(Async::NotReady) => unreachable!("dispatch not ready when conn is"),
|
Ok(Async::NotReady) => unreachable!("dispatch not ready when conn is"),
|
||||||
Err(()) => {
|
Err(()) => {
|
||||||
trace!("dispatch no longer receiving messages");
|
trace!("dispatch no longer receiving messages");
|
||||||
self.is_closing = true;
|
self.close();
|
||||||
return Ok(Async::Ready(()));
|
return Ok(Async::Ready(()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,9 +180,7 @@ where
|
|||||||
self.conn.write_head(head, body.is_some());
|
self.conn.write_head(head, body.is_some());
|
||||||
self.body_rx = body;
|
self.body_rx = body;
|
||||||
} else {
|
} else {
|
||||||
self.is_closing = true;
|
self.close();
|
||||||
//self.conn.close_read();
|
|
||||||
//self.conn.close_write();
|
|
||||||
return Ok(Async::Ready(()));
|
return Ok(Async::Ready(()));
|
||||||
}
|
}
|
||||||
} else if self.conn.has_queued_body() {
|
} else if self.conn.has_queued_body() {
|
||||||
@@ -218,17 +216,17 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_close(&mut self) -> Poll<(), ::Error> {
|
fn close(&mut self) {
|
||||||
debug_assert!(self.is_closing);
|
self.is_closing = true;
|
||||||
|
|
||||||
try_ready!(self.conn.close_and_shutdown());
|
|
||||||
self.conn.close_read();
|
self.conn.close_read();
|
||||||
self.conn.close_write();
|
self.conn.close_write();
|
||||||
self.is_closing = false;
|
|
||||||
Ok(Async::Ready(()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_done(&self) -> bool {
|
fn is_done(&self) -> bool {
|
||||||
|
if self.is_closing {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let read_done = self.conn.is_read_closed();
|
let read_done = self.conn.is_read_closed();
|
||||||
|
|
||||||
if !T::should_read_first() && read_done {
|
if !T::should_read_first() && read_done {
|
||||||
@@ -262,10 +260,6 @@ where
|
|||||||
self.poll_write()?;
|
self.poll_write()?;
|
||||||
self.poll_flush()?;
|
self.poll_flush()?;
|
||||||
|
|
||||||
if self.is_closing {
|
|
||||||
self.poll_close()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.is_done() {
|
if self.is_done() {
|
||||||
try_ready!(self.conn.shutdown());
|
try_ready!(self.conn.shutdown());
|
||||||
trace!("Dispatch::poll done");
|
trace!("Dispatch::poll done");
|
||||||
|
|||||||
Reference in New Issue
Block a user