mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
cleanup
This commit is contained in:
parent
04c1b76402
commit
cfea87251b
@ -181,13 +181,10 @@ impl Server {
|
||||
|
||||
socket.readable().await.expect("Failed to wait for socket to become readable!");
|
||||
let mut tmp = vec![0u8; 1];
|
||||
while socket.peek(&mut tmp).await.expect("Failed to peek socket!") == 0 {
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
|
||||
}
|
||||
// Authentication works a little differently than normal
|
||||
// Not sure why, but the BeamMP source code shows they
|
||||
// also only read a single byte during authentication
|
||||
socket.read_exact(&mut tmp).await.expect("Failed to read from socket!");
|
||||
if socket.read_exact(&mut tmp).await.is_ok() {
|
||||
let code = tmp[0];
|
||||
|
||||
match code as char {
|
||||
@ -283,15 +280,14 @@ impl Server {
|
||||
tokio::task::yield_now().await;
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
info!("Client pushed to joinset!");
|
||||
}
|
||||
Err(e) => error!("Failed to accept incoming connection: {:?}", e),
|
||||
}
|
||||
},
|
||||
_ = tokio::time::sleep(tokio::time::Duration::from_millis(50)) => {
|
||||
error!("time out!");
|
||||
},
|
||||
_ = tokio::time::sleep(tokio::time::Duration::from_millis(50)) => {},
|
||||
}
|
||||
|
||||
if set.is_empty() == false {
|
||||
@ -299,12 +295,8 @@ impl Server {
|
||||
// Because join_next() is cancel safe, we can simply cancel it after N duration
|
||||
// so at worst this client acceptance loop blocks for N duration
|
||||
tokio::select! {
|
||||
_ = tokio::time::sleep(tokio::time::Duration::from_millis(10)) => {
|
||||
error!("join_next timed out!");
|
||||
},
|
||||
_ = set.join_next() => {
|
||||
info!("join_next ran!");
|
||||
},
|
||||
_ = set.join_next() => {},
|
||||
_ = tokio::time::sleep(tokio::time::Duration::from_millis(10)) => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user