From 75931e5e889e80f11dfab01eb1c86787d733f8df Mon Sep 17 00:00:00 2001 From: Skye Date: Sun, 14 May 2023 06:31:00 +0900 Subject: [PATCH] fix(server): RwLocks, amirite? --- server/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 44ef43a..a9d255f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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)?;