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(subscriber): handle concurrent call to close correctly #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jlevesy
Copy link

@jlevesy jlevesy commented Sep 11, 2024

What does this PR do?

It appears that the current implementation of Close doesn't handle very well concurrent call. Indeed as it is written it allows for two goroutines calling close at the same time to have getClosed return true.

This is causing ThreeDotsLabs/watermill#351 I believe.

I propose this patch to actually use an atomic.Bool to keep track of the closed state. I think that doing this allows to prevent the issue that we're seeing.

I'm opening this as a draft for now, I would like to deploy this change and make sure it fixes something :)

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