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)?;