fix incomplete timer unqueuing that prevent any further timer in the same task #4736
+6
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue when using never ending timers such as:
Timer::at(Instant::MAX)
When such a timer is canceled and a another timer is initiated in the same task,
the new timer won't actually be added to the queue and thus will never wake.
The issue is that when the never ending timer is added to the queue,
next_expiration()
is called and will simply remove the timer from the queue (it will never be reached
so there is no point in keeping it in the queue and checking it every time), but it
will not reset the waker to None.
So when the next timer is scheduled with
schedule_wake()
, a waker will already bepresent and
schedule_wake()
will consider this item is already part of the queueand won't add it in the queue anymore, so it will also never wake !
Here is an example the exhibit this issue. First time the
select()
will be called witha never ending timer, but after the first edge change on input,
select()
iscalled with a 500ms timer that should trigger a break of the loop if no edge happens
during the 500ms.
Currently, this loop will never end. The PR fixes this issue.
For the record, this bug was introduced in 74037f0