From c202d9ba41004af1f1c7103899d6434e353ecabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 1 Aug 2020 23:50:01 +0200 Subject: [PATCH] udp, ws load test: fix clippy errors --- aquatic_udp/src/lib/tasks.rs | 38 ++++++++++++++--------------- aquatic_ws_load_test/src/network.rs | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/aquatic_udp/src/lib/tasks.rs b/aquatic_udp/src/lib/tasks.rs index 50c4fba..09472fe 100644 --- a/aquatic_udp/src/lib/tasks.rs +++ b/aquatic_udp/src/lib/tasks.rs @@ -10,12 +10,12 @@ use crate::config::Config; pub fn clean_connections_and_torrents(state: &State){ let now = Instant::now(); - let mut connections = state.connections.lock(); + { + let mut connections = state.connections.lock(); - connections.retain(|_, v| v.0 > now); - connections.shrink_to_fit(); - - ::std::mem::drop(connections); + connections.retain(|_, v| v.0 > now); + connections.shrink_to_fit(); + } let mut torrents = state.torrents.lock(); @@ -101,24 +101,24 @@ pub fn gather_and_print_statistics( let mut peers_per_torrent = Histogram::new(); - let torrents = &mut state.torrents.lock(); + { + let torrents = &mut state.torrents.lock(); - for torrent in torrents.ipv4.values(){ - let num_peers = (torrent.num_seeders + torrent.num_leechers) as u64; + for torrent in torrents.ipv4.values(){ + let num_peers = (torrent.num_seeders + torrent.num_leechers) as u64; - if let Err(err) = peers_per_torrent.increment(num_peers){ - eprintln!("error incrementing peers_per_torrent histogram: {}", err) + if let Err(err) = peers_per_torrent.increment(num_peers){ + eprintln!("error incrementing peers_per_torrent histogram: {}", err) + } + } + for torrent in torrents.ipv6.values(){ + let num_peers = (torrent.num_seeders + torrent.num_leechers) as u64; + + if let Err(err) = peers_per_torrent.increment(num_peers){ + eprintln!("error incrementing peers_per_torrent histogram: {}", err) + } } } - for torrent in torrents.ipv6.values(){ - let num_peers = (torrent.num_seeders + torrent.num_leechers) as u64; - - if let Err(err) = peers_per_torrent.increment(num_peers){ - eprintln!("error incrementing peers_per_torrent histogram: {}", err) - } - } - - ::std::mem::drop(torrents); if peers_per_torrent.entries() != 0 { println!( diff --git a/aquatic_ws_load_test/src/network.rs b/aquatic_ws_load_test/src/network.rs index d4f0619..f9d400e 100644 --- a/aquatic_ws_load_test/src/network.rs +++ b/aquatic_ws_load_test/src/network.rs @@ -95,7 +95,7 @@ impl Connection { connections.insert(*token_counter, connection); - *token_counter = *token_counter + 1; + *token_counter += 1; Ok(()) }