Skip to content

Commit 485c4b0

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 0363efb commit 485c4b0

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
@@ -635,12 +635,23 @@ impl<S: Read + Write> RawClient<S> {
635635
loop {
636636
raw_resp.clear();
637637

638-
if let Err(e) = reader.read_line(&mut raw_resp) {
639-
let error = Arc::new(e);
640-
for (_, s) in self.waiting_map.lock().unwrap().drain() {
641-
s.send(ChannelMessage::Error(error.clone()))?;
638+
match reader.read_line(&mut raw_resp) {
639+
Ok(n_bytes_read) => {
640+
if n_bytes_read == 0 {
641+
trace!("Reached UnexpectedEof");
642+
return Err(Error::IOError(std::io::Error::new(
643+
std::io::ErrorKind::UnexpectedEof,
644+
"unexpected EOF",
645+
)));
646+
}
647+
}
648+
Err(e) => {
649+
let error = Arc::new(e);
650+
for (_, s) in self.waiting_map.lock().unwrap().drain() {
651+
s.send(ChannelMessage::Error(error.clone()))?;
652+
}
653+
return Err(Error::SharedIOError(error));
642654
}
643-
return Err(Error::SharedIOError(error));
644655
}
645656
trace!("<== {}", raw_resp);
646657

0 commit comments

Comments
 (0)