From 1f763e63e452b228534964270e783e10c076d571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Mon, 18 Oct 2021 02:30:49 +0200 Subject: [PATCH] aquatic_udp: clean ConnectionMap less often --- TODO.md | 2 -- aquatic_udp/src/lib/network.rs | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index dc6c3e0..ea65cc2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ # TODO -* aquatic_udp: clean ConnectionMap less often - * access lists: * use arc-swap Cache * add CI tests diff --git a/aquatic_udp/src/lib/network.rs b/aquatic_udp/src/lib/network.rs index 8ab5d2f..82b187f 100644 --- a/aquatic_udp/src/lib/network.rs +++ b/aquatic_udp/src/lib/network.rs @@ -74,6 +74,8 @@ pub fn run_socket_worker( let timeout = Duration::from_millis(50); + let mut iter_counter = 0usize; + loop { poll.poll(&mut events, Some(timeout)) .expect("failed polling"); @@ -115,7 +117,13 @@ pub fn run_socket_worker( local_responses.drain(..), ); - connections.clean(); + iter_counter += 1; + + if iter_counter == 1000 { + connections.clean(); + + iter_counter = 0; + } } }