Don't panic the tokio worker thread when deserialize() fails
This commit is contained in:
parent
f341b2ec10
commit
79ece53e3c
|
@ -116,8 +116,14 @@ fn main() {
|
||||||
|
|
||||||
let processor = reader
|
let processor = reader
|
||||||
.for_each(move |bytes| {
|
.for_each(move |bytes| {
|
||||||
let req: DroneRequest =
|
let req: DroneRequest = deserialize(&bytes).or_else(|err| {
|
||||||
deserialize(&bytes).expect("deserialize packet in drone");
|
use std::io;
|
||||||
|
Err(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
format!("deserialize packet in drone: {:?}", err),
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
|
||||||
println!("Airdrop requested...");
|
println!("Airdrop requested...");
|
||||||
// let res = drone2.lock().unwrap().check_rate_limit(client_ip);
|
// let res = drone2.lock().unwrap().check_rate_limit(client_ip);
|
||||||
let res1 = drone2.lock().unwrap().send_airdrop(req);
|
let res1 = drone2.lock().unwrap().send_airdrop(req);
|
||||||
|
@ -127,14 +133,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.and_then(|()| {
|
|
||||||
println!("Socket received FIN packet and closed connection");
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.or_else(|err| {
|
|
||||||
println!("Socket closed with error: {:?}", err);
|
|
||||||
Err(err)
|
|
||||||
})
|
|
||||||
.then(|result| {
|
.then(|result| {
|
||||||
println!("Socket closed with result: {:?}", result);
|
println!("Socket closed with result: {:?}", result);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue