forked from M-Labs/artiq-zynq
comms: handle connection termination
This commit is contained in:
parent
895a3f47e2
commit
48025339b3
|
@ -107,8 +107,15 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
|
||||||
expect(&stream, b"ARTIQ coredev\n").await?;
|
expect(&stream, b"ARTIQ coredev\n").await?;
|
||||||
debug!("received connection");
|
debug!("received connection");
|
||||||
loop {
|
loop {
|
||||||
if !expect(&stream, &[0x5a, 0x5a, 0x5a, 0x5a]).await? {
|
match expect(&stream, &[0x5a, 0x5a, 0x5a, 0x5a]).await {
|
||||||
return Err(Error::UnexpectedPattern)
|
Ok(true) => {}
|
||||||
|
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?)
|
let request: Request = FromPrimitive::from_i8(read_i8(&stream).await?)
|
||||||
.ok_or(Error::UnrecognizedPacket)?;
|
.ok_or(Error::UnrecognizedPacket)?;
|
||||||
|
|
Loading…
Reference in New Issue