forked from M-Labs/artiq-zynq
use new smoltcp error code
This commit is contained in:
parent
0ae2138034
commit
21d98711c1
|
@ -94,13 +94,13 @@ async fn read_request(stream: &TcpStream, allow_close: bool) -> Result<Option<Re
|
||||||
Ok(true) => {}
|
Ok(true) => {}
|
||||||
Ok(false) =>
|
Ok(false) =>
|
||||||
return Err(Error::UnexpectedPattern),
|
return Err(Error::UnexpectedPattern),
|
||||||
Err(smoltcp::Error::Illegal) => {
|
Err(smoltcp::Error::Finished) => {
|
||||||
if allow_close {
|
if allow_close {
|
||||||
info!("peer closed connection");
|
info!("peer closed connection");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
} else {
|
} else {
|
||||||
error!("peer unexpectedly closed connection");
|
error!("peer unexpectedly closed connection");
|
||||||
return Err(smoltcp::Error::Illegal)?;
|
return Err(smoltcp::Error::Finished)?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
|
|
|
@ -121,7 +121,7 @@ async fn handle_connection(
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let msg = read_i8(stream).await;
|
let msg = read_i8(stream).await;
|
||||||
if let Err(smoltcp::Error::Illegal) = msg {
|
if let Err(smoltcp::Error::Finished) = msg {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let msg: Request = FromPrimitive::from_i8(msg?).ok_or(Error::UnrecognizedPacket)?;
|
let msg: Request = FromPrimitive::from_i8(msg?).ok_or(Error::UnrecognizedPacket)?;
|
||||||
|
|
|
@ -184,7 +184,7 @@ pub fn start(timer: GlobalTimer) {
|
||||||
info!("received connection");
|
info!("received connection");
|
||||||
let result = handle_connection(&stream, timer).await;
|
let result = handle_connection(&stream, timer).await;
|
||||||
match result {
|
match result {
|
||||||
Err(Error::NetworkError(smoltcp::Error::Illegal)) => info!("peer closed connection"),
|
Err(Error::NetworkError(smoltcp::Error::Finished)) => info!("peer closed connection"),
|
||||||
Err(error) => warn!("connection terminated: {}", error),
|
Err(error) => warn!("connection terminated: {}", error),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue