From f9640e9b7e13a498d063c59401d7472c861028a0 Mon Sep 17 00:00:00 2001 From: Vilgot Fredenberg <26655508+vilgotf@users.noreply.github.com> Date: Mon, 14 Nov 2022 12:01:07 +0100 Subject: [PATCH] fix: treat `UnexpectedEof` as having read 0 bytes --- src/protocol/frame/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/protocol/frame/mod.rs b/src/protocol/frame/mod.rs index 39066be..da53488 100644 --- a/src/protocol/frame/mod.rs +++ b/src/protocol/frame/mod.rs @@ -151,7 +151,13 @@ impl FrameCodec { } // Not enough data in buffer. - let size = self.in_buffer.read_from(stream)?; + let size = self.in_buffer.read_from(stream).or_else(|error| { + if error.kind() == IoErrorKind::UnexpectedEof { + Ok(0) + } else { + Err(error) + } + })?; if size == 0 { trace!("no frame received"); return Ok(None);