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

Correctly reschedule an initially non-recurring timer when a new definite period is specified #105

Conversation

mattrm456
Copy link
Contributor

There is a bug when a timer is rescheduled and transitions from non-recurring to recurring. The bug occurs in the following sequence of operations:

  1. A non-oneshot timer is created and scheduled to some deadline far in the future
  2. The timer is quickly rescheduled to some near deadline and assigned a period by which it recurrs
  3. The timer fires at the initial deadline but does not subsequently fire (i.e. the period is not honored)

It's possible that this bug was introduced ntcs::Chronology was revised to become implemented by ntcs::SkipList: when we update the ntcs::Chronology::DeadlineMapEntry in the skip list (rather than adding a new entry) we do not update the initial period to the new period. It's also possible this bug pre-dated that revision, however.

In any case, the current ntcs::SkipList-based implementation does not need ntcs::Chronology::DeadlineMapEntry::d_period nor d_oneShot, we can always safely access those fields from the associated ntci::Timer object itself, which are always written to a read from the same ntcs::Chronology::d_mutex.

This PR removes those fields from ntcs::Chronology::DeadlineMapEntry and uses the necessary fields directly from ntci::Timer.

Copy link
Contributor

@smtrfnv smtrfnv left a comment

Choose a reason for hiding this comment

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

Please see my PR to your branch

@mattrm456 mattrm456 merged commit f73e830 into bloomberg:main Dec 13, 2023
1 check failed
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.

2 participants