fix(server): RwLocks, amirite?

This commit is contained in:
Skye 2023-05-14 06:31:00 +09:00
parent afa62d4ab6
commit 75931e5e88
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -365,8 +365,10 @@ async fn accept_minecraft_connection(mut stream: TcpStream) -> Result<()> {
}
let handshake = Handshake::new(&packet?).await?;
info!("Minecraft client {} is connecting to {}", addr, handshake.server_address);
if let Some(sender) = ROUTING_MAP.read().await.get(&handshake.server_address) {
let mut handle = ChannelHandle::new(sender, addr).await?;
let map = ROUTING_MAP.read().await;
if let Some(sender) = map.get(&handshake.server_address).cloned() {
drop(map);
let mut handle: ChannelHandle = ChannelHandle::new(&sender, addr).await?;
let mut buf = vec![];
handshake.send(&mut buf).await?;
handle.send(buf)?;