diff --git a/src/server.rs b/src/server.rs index 67a6b77..338cc81 100644 --- a/src/server.rs +++ b/src/server.rs @@ -12,13 +12,14 @@ use crate::socketwrapper::Listener; pub async fn run(config: &Config) -> Result<()> { let instance_map = InstanceMap::new(config).await; let next_client_id = AtomicUsize::new(0); + let next_client_id = || next_client_id.fetch_add(1, Ordering::Relaxed); let listener = Listener::bind(&config.listen).await .context("listen")?; loop { match listener.accept().await { Ok((socket, _addr)) => { - let client_id = next_client_id.fetch_add(1, Ordering::Relaxed); + let client_id = next_client_id(); let instance_map = instance_map.clone(); task::spawn(