Skip to content

Commit

Permalink
ignore abnormal latency
Browse files Browse the repository at this point in the history
  • Loading branch information
rustdesk committed Aug 12, 2021
1 parent 2102813 commit a76916c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rendezvous_mediator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ impl RendezvousMediator {
loop {
let mut update_latency = || {
last_register_resp = SystemTime::now();
fails = 0;
let mut latency = last_register_resp
.duration_since(last_register_sent)
.map(|d| d.as_micros() as i64)
.unwrap_or(0);
if latency < 0 || latency > 1_000_000 {
return;
}
if ema_latency == 0 {
ema_latency = latency;
} else {
Expand All @@ -130,7 +134,6 @@ impl RendezvousMediator {
log::debug!("Latency of {}: {}ms", host, latency as f64 / 1000.);
old_latency = latency;
}
fails = 0;
};
select! {
Some(Ok((bytes, _))) = socket.next() => {
Expand Down

0 comments on commit a76916c

Please sign in to comment.