From e892d9178e120d4e335b35644292d9311a3eddcd Mon Sep 17 00:00:00 2001 From: GyulyVGC Date: Sat, 21 Jun 2025 02:27:43 +0200 Subject: [PATCH] don't reset dropped_packets in the interval with no exchanged data --- src/networking/parse_packets.rs | 4 ++-- src/networking/types/info_traffic.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/networking/parse_packets.rs b/src/networking/parse_packets.rs index b0686818..43be9c4c 100644 --- a/src/networking/parse_packets.rs +++ b/src/networking/parse_packets.rs @@ -432,7 +432,7 @@ fn maybe_send_tick_run_live( first_packet_ticks.and_then(|i| i.checked_add(Duration::from_millis(1000))); let _ = tx.send_blocking(BackendTrafficMessage::TickRun( cap_id, - info_traffic_msg.take_but_leave_timestamp(), + info_traffic_msg.take_but_leave_something(), new_hosts_to_send.lock().unwrap().drain(..).collect(), false, )); @@ -460,7 +460,7 @@ fn maybe_send_tick_run_offline( next_packet_timestamp.secs() - info_traffic_msg.last_packet_timestamp.secs(); let _ = tx.send_blocking(BackendTrafficMessage::TickRun( cap_id, - info_traffic_msg.take_but_leave_timestamp(), + info_traffic_msg.take_but_leave_something(), new_hosts_to_send.lock().unwrap().drain(..).collect(), false, )); diff --git a/src/networking/types/info_traffic.rs b/src/networking/types/info_traffic.rs index cfd84143..e371a7b1 100644 --- a/src/networking/types/info_traffic.rs +++ b/src/networking/types/info_traffic.rs @@ -158,9 +158,10 @@ pub fn add_packet(&mut self, bytes: u128, traffic_direction: TrafficDirection) { } } - pub fn take_but_leave_timestamp(&mut self) -> Self { + pub fn take_but_leave_something(&mut self) -> Self { let info_traffic = Self { last_packet_timestamp: self.last_packet_timestamp, + dropped_packets: self.dropped_packets, ..Self::default() }; std::mem::replace(self, info_traffic)