don't error on dropped connections
This commit is contained in:
parent
4cca315f61
commit
b8afaba4ef
12
src/main.rs
12
src/main.rs
@ -21,7 +21,7 @@ use tokio::{
|
||||
sync::Mutex,
|
||||
time::sleep,
|
||||
};
|
||||
use tracing::{error, info, instrument, warn, Level};
|
||||
use tracing::{debug, error, info, instrument, warn, Level};
|
||||
use tracing_subscriber::fmt::time::FormatTime;
|
||||
|
||||
use crate::packets::PacketKind;
|
||||
@ -247,7 +247,14 @@ async fn connection_handler(
|
||||
|
||||
let error = match res {
|
||||
Err(_) => Some("internal server error".to_owned()),
|
||||
Ok(Err(err)) => Some(err.to_string()),
|
||||
Ok(Err(err)) => match err.downcast_ref::<std::io::Error>() {
|
||||
Some(io_error) if io_error.kind() == std::io::ErrorKind::UnexpectedEof => {
|
||||
debug!(%addr, "Client dropped their connection");
|
||||
// don't print an error on dropped connections
|
||||
None
|
||||
}
|
||||
_ => Some(err.to_string()),
|
||||
},
|
||||
Ok(Ok(())) => None,
|
||||
};
|
||||
|
||||
@ -264,6 +271,7 @@ async fn connection_handler(
|
||||
length: packet.data.len().try_into().unwrap(), // this will never fail, as we just truncated the vector
|
||||
};
|
||||
|
||||
// Attempt to notify the client of the failure
|
||||
let (_, mut writer) = stream.split();
|
||||
_ = packet.send(&mut writer).await;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user