From 5646508c3ecc0e3d68357d510edab5b36ac247c6 Mon Sep 17 00:00:00 2001 From: Vladimir Stoilov Date: Tue, 15 Oct 2024 10:47:06 +0300 Subject: [PATCH] [windows_kext] Fix synchronization bug --- windows_kext/driver/src/bandwidth.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/windows_kext/driver/src/bandwidth.rs b/windows_kext/driver/src/bandwidth.rs index 37fc405b0..0105ac72e 100644 --- a/windows_kext/driver/src/bandwidth.rs +++ b/windows_kext/driver/src/bandwidth.rs @@ -3,11 +3,8 @@ use protocol::info::{BandwidthValueV4, BandwidthValueV6, Info}; use smoltcp::wire::{IpProtocol, Ipv4Address, Ipv6Address}; use wdk::rw_spin_lock::RwSpinLock; -#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)] -pub struct Key -where - Address: Eq + PartialEq, -{ +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)] +pub struct Key { pub local_ip: Address, pub local_port: u16, pub remote_ip: Address, @@ -139,10 +136,10 @@ impl Bandwidth { let stats_map; { let _guard = self.stats_udp_v6_lock.write_lock(); - if self.stats_tcp_v6.is_empty() { + if self.stats_udp_v6.is_empty() { return None; } - stats_map = core::mem::replace(&mut self.stats_tcp_v6, BTreeMap::new()); + stats_map = core::mem::replace(&mut self.stats_udp_v6, BTreeMap::new()); } let mut values = alloc::vec::Vec::with_capacity(stats_map.len()); @@ -234,7 +231,7 @@ impl Bandwidth { ); } - fn update( + fn update( map: &mut BTreeMap, Value>, lock: &mut RwSpinLock, key: Key
,