ignore abnormal latency
This commit is contained in:
parent
2102813ed9
commit
a76916c520
@ -111,10 +111,14 @@ impl RendezvousMediator {
|
|||||||
loop {
|
loop {
|
||||||
let mut update_latency = || {
|
let mut update_latency = || {
|
||||||
last_register_resp = SystemTime::now();
|
last_register_resp = SystemTime::now();
|
||||||
|
fails = 0;
|
||||||
let mut latency = last_register_resp
|
let mut latency = last_register_resp
|
||||||
.duration_since(last_register_sent)
|
.duration_since(last_register_sent)
|
||||||
.map(|d| d.as_micros() as i64)
|
.map(|d| d.as_micros() as i64)
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
if latency < 0 || latency > 1_000_000 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ema_latency == 0 {
|
if ema_latency == 0 {
|
||||||
ema_latency = latency;
|
ema_latency = latency;
|
||||||
} else {
|
} else {
|
||||||
@ -130,7 +134,6 @@ impl RendezvousMediator {
|
|||||||
log::debug!("Latency of {}: {}ms", host, latency as f64 / 1000.);
|
log::debug!("Latency of {}: {}ms", host, latency as f64 / 1000.);
|
||||||
old_latency = latency;
|
old_latency = latency;
|
||||||
}
|
}
|
||||||
fails = 0;
|
|
||||||
};
|
};
|
||||||
select! {
|
select! {
|
||||||
Some(Ok((bytes, _))) = socket.next() => {
|
Some(Ok((bytes, _))) = socket.next() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user