don't reset dropped_packets in the interval with no exchanged data

This commit is contained in:
GyulyVGC
2025-06-21 02:27:43 +02:00
parent 75d2ad764f
commit e892d9178e
2 changed files with 4 additions and 3 deletions

View File

@@ -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,
));

View File

@@ -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)