Skip to content

Commit

Permalink
[windows_kext] Fix synchronization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Oct 15, 2024
1 parent f41ff87 commit 5646508
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions windows_kext/driver/src/bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address: Ord>
where
Address: Eq + PartialEq,
{
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)]
pub struct Key<Address: Ord> {
pub local_ip: Address,
pub local_port: u16,
pub remote_ip: Address,
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -234,7 +231,7 @@ impl Bandwidth {
);
}

fn update<Address: Eq + PartialEq + core::hash::Hash + Ord>(
fn update<Address: Ord>(
map: &mut BTreeMap<Key<Address>, Value>,
lock: &mut RwSpinLock,
key: Key<Address>,
Expand Down

0 comments on commit 5646508

Please sign in to comment.