Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Jan 26, 2024
2 parents 91c6995 + 46b4e21 commit 472da0b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/rendezvous_mediator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ impl RendezvousMediator {
let mut latency = last_register_sent
.map(|x| x.elapsed().as_micros() as i64)
.unwrap_or(0);
last_register_sent = None;
if latency < 0 || latency > 1_000_000 {
return;
}
Expand Down Expand Up @@ -216,11 +217,9 @@ impl RendezvousMediator {
continue;
}
last_timer = now;
let elapsed_resp = last_register_resp.map(|x| x.elapsed().as_millis() as i64).unwrap_or(REG_INTERVAL);
let timeout = (elapsed_resp - last_register_sent.map(|x| x.elapsed().as_millis() as i64).unwrap_or(REG_INTERVAL)) > REG_TIMEOUT;
if timeout || elapsed_resp >= REG_INTERVAL {
rz.register_peer(Sink::Framed(&mut socket, &addr)).await?;
last_register_sent = now;
let expired = last_register_resp.map(|x| x.elapsed().as_millis() as i64 >= REG_INTERVAL).unwrap_or(true);
let timeout = last_register_sent.map(|x| x.elapsed().as_millis() as i64 >= REG_TIMEOUT).unwrap_or(false);
if timeout || (last_register_sent.is_none() && expired) {
if timeout {
fails += 1;
if fails > MAX_FAILS2 {
Expand All @@ -240,6 +239,8 @@ impl RendezvousMediator {
old_latency = 0;
}
}
rz.register_peer(Sink::Framed(&mut socket, &addr)).await?;
last_register_sent = now;
}
}
}
Expand Down

0 comments on commit 472da0b

Please sign in to comment.