overflow check when timer expired while disconnected

This commit is contained in:
Florian Stecker 2023-01-02 10:54:44 +01:00
parent c555414639
commit 803084af12

View File

@ -104,7 +104,12 @@ pub fn run() -> AResult<()> {
wait_time = interval_duration;
} else {
wait_time = interval_duration - elapsed;
// wait for the remaining time until interval_duration
// if the time is already up, that means we're not connected currently
// in that case, just wait 1/2 hour, once the connection is reestablished
// the main thread will unpark us anyway
wait_time = interval_duration.checked_sub(elapsed)
.unwrap_or(Duration::from_secs(1800));
}
}
})