forked from M-Labs/nac3
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(false) =>
|
||||
return Err(Error::UnexpectedPattern),
|
||||
Err(smoltcp::Error::Illegal) => {
|
||||
Err(smoltcp::Error::Finished) => {
|
||||
if allow_close {
|
||||
info!("peer closed connection");
|
||||
return Ok(None);
|
||||
} else {
|
||||
error!("peer unexpectedly closed connection");
|
||||
return Err(smoltcp::Error::Illegal)?;
|
||||
return Err(smoltcp::Error::Finished)?;
|
||||
}
|
||||
},
|
||||
Err(e) =>
|
||||
|
|
|
@ -121,7 +121,7 @@ async fn handle_connection(
|
|||
|
||||
loop {
|
||||
let msg = read_i8(stream).await;
|
||||
if let Err(smoltcp::Error::Illegal) = msg {
|
||||
if let Err(smoltcp::Error::Finished) = msg {
|
||||
return Ok(());
|
||||
}
|
||||
let msg: Request = FromPrimitive::from_i8(msg?).ok_or(Error::UnrecognizedPacket)?;
|
||||
|
|
|
@ -184,7 +184,7 @@ pub fn start(timer: GlobalTimer) {
|
|||
info!("received connection");
|
||||
let result = handle_connection(&stream, timer).await;
|
||||
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),
|
||||
_ => (),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue