From 48025339b359dfbb569920a431889e6626ff8dc0 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 1 May 2020 02:09:00 +0200 Subject: [PATCH] comms: handle connection termination --- firmware/runtime/src/comms.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/firmware/runtime/src/comms.rs b/firmware/runtime/src/comms.rs index 51796ff..1232e29 100644 --- a/firmware/runtime/src/comms.rs +++ b/firmware/runtime/src/comms.rs @@ -107,8 +107,15 @@ async fn handle_connection(stream: &TcpStream, control: Rc {} + Ok(false) => + return Err(Error::UnexpectedPattern), + // peer has closed the connection + Err(smoltcp::Error::Illegal) => + return Ok(()), + Err(e) => + return Err(e)?, } let request: Request = FromPrimitive::from_i8(read_i8(&stream).await?) .ok_or(Error::UnrecognizedPacket)?;