fix(client): remove idle connections when read eof is found

This commit is contained in:
Sean McArthur
2017-11-28 17:13:54 -08:00
parent 9f21241002
commit cecef9d402
2 changed files with 16 additions and 11 deletions

View File

@@ -874,13 +874,6 @@ mod tests {
let mut conn = Conn::<_, proto::Chunk, ClientTransaction>::new(io, Default::default()); let mut conn = Conn::<_, proto::Chunk, ClientTransaction>::new(io, Default::default());
conn.state.busy(); conn.state.busy();
match conn.poll() {
Ok(Async::NotReady) => {},
other => panic!("unexpected frame: {:?}", other)
}
// once mid-request, returns the error
conn.state.writing = super::Writing::KeepAlive;
match conn.poll() { match conn.poll() {
Err(ref err) if err.kind() == ::std::io::ErrorKind::UnexpectedEof => {}, Err(ref err) if err.kind() == ::std::io::ErrorKind::UnexpectedEof => {},
other => panic!("unexpected frame: {:?}", other) other => panic!("unexpected frame: {:?}", other)

View File

@@ -184,13 +184,25 @@ where
} }
fn is_done(&self) -> bool { fn is_done(&self) -> bool {
trace!(
"is_done; read={}, write={}, should_poll={}, body={}",
self.conn.is_read_closed(),
self.conn.is_write_closed(),
self.dispatch.should_poll(),
self.body_rx.is_some(),
);
let read_done = self.conn.is_read_closed(); let read_done = self.conn.is_read_closed();
if !T::should_read_first() && read_done {
// a client that cannot read may was well be done.
true
} else {
let write_done = self.conn.is_write_closed() || let write_done = self.conn.is_write_closed() ||
(!self.dispatch.should_poll() && self.body_rx.is_none()); (!self.dispatch.should_poll() && self.body_rx.is_none());
read_done && write_done read_done && write_done
} }
} }
}
impl<D, Bs, I, B, T, K> Future for Dispatcher<D, Bs, I, B, T, K> impl<D, Bs, I, B, T, K> Future for Dispatcher<D, Bs, I, B, T, K>