Skip to content

Commit

Permalink
dont borrow_mut cliens during send_to_client calls
Browse files Browse the repository at this point in the history
  • Loading branch information
gwen-lg committed Dec 21, 2024
1 parent 6311d28 commit be9d218
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion puffin_http/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,15 @@ impl PuffinServerSend {
let packet: Packet = packet.into();

// Send frame to clients, remove disconnected clients and update num_clients var
let mut clients = self.clients.borrow_mut();
let clients = self.clients.borrow();
let mut idx_to_remove = Vec::new();
for (idx, client) in clients.iter().enumerate() {
if !Self::send_to_client(client, packet.clone()).await {
idx_to_remove.push(idx);
}
}

let mut clients = self.clients.borrow_mut();
idx_to_remove.iter().rev().for_each(|idx| {
clients.remove(*idx);
});
Expand Down

0 comments on commit be9d218

Please sign in to comment.