Skip to content

Commit cecef9d

Browse files
committed
fix(client): remove idle connections when read eof is found
1 parent 9f21241 commit cecef9d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/proto/conn.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -869,18 +869,11 @@ mod tests {
869869
other => panic!("unexpected frame: {:?}", other)
870870
}
871871

872-
// client
872+
// client
873873
let io = AsyncIo::new_buf(vec![], 1);
874874
let mut conn = Conn::<_, proto::Chunk, ClientTransaction>::new(io, Default::default());
875875
conn.state.busy();
876876

877-
match conn.poll() {
878-
Ok(Async::NotReady) => {},
879-
other => panic!("unexpected frame: {:?}", other)
880-
}
881-
882-
// once mid-request, returns the error
883-
conn.state.writing = super::Writing::KeepAlive;
884877
match conn.poll() {
885878
Err(ref err) if err.kind() == ::std::io::ErrorKind::UnexpectedEof => {},
886879
other => panic!("unexpected frame: {:?}", other)

src/proto/dispatch.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,23 @@ where
184184
}
185185

186186
fn is_done(&self) -> bool {
187+
trace!(
188+
"is_done; read={}, write={}, should_poll={}, body={}",
189+
self.conn.is_read_closed(),
190+
self.conn.is_write_closed(),
191+
self.dispatch.should_poll(),
192+
self.body_rx.is_some(),
193+
);
187194
let read_done = self.conn.is_read_closed();
188-
let write_done = self.conn.is_write_closed() ||
189-
(!self.dispatch.should_poll() && self.body_rx.is_none());
190195

191-
read_done && write_done
196+
if !T::should_read_first() && read_done {
197+
// a client that cannot read may was well be done.
198+
true
199+
} else {
200+
let write_done = self.conn.is_write_closed() ||
201+
(!self.dispatch.should_poll() && self.body_rx.is_none());
202+
read_done && write_done
203+
}
192204
}
193205
}
194206

0 commit comments

Comments
 (0)