handle timeouts based on the existence of last_handshake

This commit is contained in:
shimunn 2019-04-04 18:59:17 +02:00
parent 2acbb6d574
commit a2cda16977

View File

@ -30,23 +30,9 @@ pub(crate) fn gen_events(
}
}
let timedout_now = || {
if let Some(shake) = cur.last_handshake {
if let Ok(el) = shake.elapsed() {
return el > timeout && el + poll_interval < timeout;
}
}
true
};
let timedout_now = || !cur.last_handshake.is_some();
let timedout_prev = || {
if let Some(shake) = prev.last_handshake {
if let Ok(el) = shake.elapsed().map(|el| el - poll_interval) {
return el > timeout && el < timeout + poll_interval;
}
}
true
};
let timedout_prev = || !prev.last_handshake.is_some();
match (timedout_prev(), timedout_now()) {
(false, true) => listeners.disconnected(&cur),