Skip to content

Commit

Permalink
TrafficStatus improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Jun 7, 2024
1 parent 9fd46c1 commit 057b77b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/traffic_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ lazy_static::lazy_static! {
}

pub(crate) fn traffic_status_update(delta_tx: usize, delta_rx: usize) -> Result<()> {
{
let is_none_or_error = TRAFFIC_STATUS_CALLBACK.lock().map(|guard| guard.is_none()).unwrap_or_else(|e| {
log::error!("Failed to acquire lock: {}", e);
true
});
if is_none_or_error {
return Ok(());
}
}
{
let mut traffic_status = TRAFFIC_STATUS.write().map_err(|e| Error::from(e.to_string()))?;
traffic_status.tx += delta_tx as u64;
Expand Down

0 comments on commit 057b77b

Please sign in to comment.