Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sleep timers during OS suspend #1027

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Fix sleep timers during OS suspend #1027

merged 1 commit into from
Oct 9, 2023

Conversation

calyptobai
Copy link
Contributor

On some platforms, tokio::time::sleep will sleep according to system uptime, not according to the wall clock. This means that for some operations that are time-sensitive, like token refreshes, tasks will sleep for too long when waking up from an OS suspend.

To fix this, we introduce sleep_systime, which sleeps in small increments, checking wall clock time on wakeup, and otherwise marshalls out directly to tokio::time::sleep for short durations as they don't generally cause usability issues.

Closes BLO-1707

On some platforms, `tokio::time::sleep` will sleep according to system
uptime, not according to the wall clock. This means that for some
operations that are time-sensitive, like token refreshes, tasks will
sleep for too long when waking up from an OS suspend.

To fix this, we introduce `sleep_systime`, which sleeps in small
increments, checking wall clock time on wakeup, and otherwise marshalls
out directly to `tokio::time::sleep` for short durations as they don't
generally cause usability issues.
Copy link
Contributor

@rsdy rsdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty clean to me.

@ggordonhall ggordonhall merged commit 315faba into main Oct 9, 2023
1 check passed
@ggordonhall ggordonhall deleted the fix-suspend-timers branch October 9, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants