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 condition #11

Merged
merged 1 commit into from
Nov 11, 2021
Merged

Fix race condition #11

merged 1 commit into from
Nov 11, 2021

Conversation

marcinwyszynski
Copy link
Owner

This fixes a race condition whereby calling Close does not stop the goroutine that's executing the start function. After the ticker is stopped, the flushTrottled executed in the loop will wait for the tick forever. And that's because stopping the ticker does not close its channel.

By adding a separate channel to track stop events we can prevent this race condition and have the start function terminate immediately once the writer is stopped.

@marcinwyszynski marcinwyszynski self-assigned this Nov 11, 2021
@marcinwyszynski marcinwyszynski added the bug Something isn't working label Nov 11, 2021
@marcinwyszynski marcinwyszynski merged commit 173cd57 into master Nov 11, 2021
@marcinwyszynski marcinwyszynski deleted the fix-race-condition branch November 11, 2021 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant