From 5d3bef50a289db143f1c4ca5e46f8816d8b72b3d Mon Sep 17 00:00:00 2001 From: Karel Kremel Date: Wed, 26 Jun 2024 22:55:25 +0200 Subject: [PATCH] lesson 13 --- lesson13/server13/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lesson13/server13/src/main.rs b/lesson13/server13/src/main.rs index a65f811..a15ccdd 100644 --- a/lesson13/server13/src/main.rs +++ b/lesson13/server13/src/main.rs @@ -38,8 +38,6 @@ fn listen_and_accept(address: String) -> Result<()> { let clients_clone = clients.clone(); thread::spawn(move || loop { - let mut clients_lock = clients_clone.lock(); - let mut peers_to_remove = vec![]; let message = match incoming_message(&mut stream) { Ok(msg) => msg, Err(e) => { @@ -49,6 +47,8 @@ fn listen_and_accept(address: String) -> Result<()> { }; // message other clients + let mut clients_lock = clients_clone.lock(); + let mut peers_to_remove = vec![]; for (peer_addr, peer_stream) in clients_lock.iter_mut() { if *peer_addr == addr { continue;