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 race in timer stoppage #3281

Merged
merged 1 commit into from
Aug 8, 2024
Merged

Fix race in timer stoppage #3281

merged 1 commit into from
Aug 8, 2024

Conversation

StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Aug 8, 2024

Why this should be merged

It is possible for:

  1. Stop to return false
  2. have the select statement run before the event is pushed to the timer.C channel.
  3. Have the select statement run the default case
  4. Have the timer then push the event onto the timer.C channel
  5. The timerPool will then include a timer that has already fired (breaking the documented invariant)

How this works

Rather than draining the channel in the defer (which doesn't have enough information to safely drain the channel) - the channel is drained in the for loop.

How this was tested

Open to feedback on how to test this, It seems like any test for this would be inherently racy... But open to suggestions.

@StephenButtolph StephenButtolph added bug Something isn't working networking This involves networking labels Aug 8, 2024
@StephenButtolph StephenButtolph added this to the v1.11.11 milestone Aug 8, 2024
@StephenButtolph StephenButtolph self-assigned this Aug 8, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Aug 8, 2024
Merged via the queue into master with commit 9e67efe Aug 8, 2024
21 checks passed
@StephenButtolph StephenButtolph deleted the fix-racy-timer branch August 8, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working networking This involves networking
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants