Skip to content

Process timers set for exactly now#73

Merged
taiki-e merged 1 commit intosmol-rs:masterfrom
sporksmith:now-timer
Nov 21, 2021
Merged

Process timers set for exactly now#73
taiki-e merged 1 commit intosmol-rs:masterfrom
sporksmith:now-timer

Conversation

@sporksmith
Copy link
Copy Markdown
Contributor

@sporksmith sporksmith commented Nov 19, 2021

This fixes a bug wherein the first timer set for exactly now ends up
in the pending list instead of the ready list, eventually resulting
in polling with a timeout of 0.

Under normal circumstances this bug would trigger very rarely, and when
it did would only result in one spurious "loop", since the next time the
timers are checked, time will have advanced.

However, this bug can cause misbehavior and deadlock in emulated
environments. e.g., in the Shadow emulator, time only moves forward when
a blocking syscall is performed, so this bug causes deadlock:
https://gitlab.torproject.org/tpo/core/arti/-/issues/174#note_2762399

This fixes a bug wherein the first timer set for exactly `now` ends up
in the `pending` list instead of the `ready` list, eventually resulting
in polling with a timeout of 0.

Under normal circumstances this bug would trigger very rarely, and when
it did would only result in one spurious "loop", since the next time the
timers are checked, time will have advanced.

However, this bug can cause misbehavior and deadlock in emulated
environments. e.g., in the Shadow emulator, time only moves forward when
a blocking syscall is performed, so this bug causes deadlock:
https://gitlab.torproject.org/tpo/core/arti/-/issues/174#note_2762399
Copy link
Copy Markdown
Collaborator

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@taiki-e taiki-e merged commit aa0d0c8 into smol-rs:master Nov 21, 2021
@sporksmith
Copy link
Copy Markdown
Contributor Author

Thanks for the quick review and merge!

@sporksmith
Copy link
Copy Markdown
Contributor Author

Hi, is it possible to get a release, so that we can avoid a git-based dependency?

@taiki-e
Copy link
Copy Markdown
Collaborator

taiki-e commented May 26, 2022

Published in 1.7.0.
Thanks for the ping on this, I had forgotten that there's an unreleased change.

@sporksmith
Copy link
Copy Markdown
Contributor Author

Published in 1.7.0.
Thanks for the ping on this, I had forgotten that there's an unreleased change.

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants