Skip to content

Commit 17f66bc

Browse files
committed
Return UnexpectedEof error if we read 0 bytes from stream
Previously we'd then fail on the deserialization step, which is odd. Signed-off-by: Elias Rohrer <dev@tnull.de>
1 parent 87da90b commit 17f66bc

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/raw_client.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,23 @@ impl<S: Read + Write> RawClient<S> {
640640
loop {
641641
raw_resp.clear();
642642

643-
if let Err(e) = reader.read_line(&mut raw_resp) {
644-
let error = Arc::new(e);
645-
for (_, s) in self.waiting_map.lock().unwrap().drain() {
646-
s.send(ChannelMessage::Error(error.clone()))?;
643+
match reader.read_line(&mut raw_resp) {
644+
Ok(n_bytes_read) => {
645+
if n_bytes_read == 0 {
646+
trace!("Reached UnexpectedEof");
647+
return Err(Error::IOError(std::io::Error::new(
648+
std::io::ErrorKind::UnexpectedEof,
649+
"unexpected EOF",
650+
)));
651+
}
652+
}
653+
Err(e) => {
654+
let error = Arc::new(e);
655+
for (_, s) in self.waiting_map.lock().unwrap().drain() {
656+
s.send(ChannelMessage::Error(error.clone()))?;
657+
}
658+
return Err(Error::SharedIOError(error));
647659
}
648-
return Err(Error::SharedIOError(error));
649660
}
650661
trace!("<== {}", raw_resp);
651662

0 commit comments

Comments
 (0)