Fix: Continue sync and lock timer during system sleep #207
Fix: Continue sync and lock timer during system sleep #207
Conversation
…leep Also added jetbrains project folders to .gitignore
|
i'm not really a fan of switching this to polling every second (that's pretty bad from a power usage perspective), and while this does fix the issue of tracking elapsed time during sleep, it instead opens up the possibility of someone keeping the vault unlocked by repeatedly setting the time backwards (this code would catch that if it set it back further than the current second, but you could easily do a thing which runs more frequently than that and still fiddles with the time while not getting caught by that check). ideally tokio would provide a call that used a boot time clock directly (relevant issue is here tokio-rs/tokio#3185) but until that happens, i'd rather see an implementation which used an AsyncFd wrapper around a timerfd which is configured to use CLOCK_BOOTTIME (on linux, falling back to the existing tokio::time::sleep implementation on other platforms). |
This commit fixes a bug were the timers for sync and vault lock did not "continue" during system sleep because of the use of
tokio::time::sleepwhich uses the monotonic clock.Did only test on Linux, although according to https://doc.rust-lang.org/std/time/struct.SystemTime.html#platform-specific-behavior,
SystemTimeworks on all platforms.As SystemTime can be manipulated by the user, the timers elapse completely when time went backwards for security reasons.