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 close of closed channel #427

Merged
merged 2 commits into from
Jun 15, 2021
Merged

Fix close of closed channel #427

merged 2 commits into from
Jun 15, 2021

Conversation

gammazero
Copy link
Contributor

This happens when there are multiple subscriptions to a topic and a single subscription is canceled twice.

FIxes #425

This happens when there are multiple subscriptions to a topic and a single subscription is canceled twice.
subscription.go Outdated
Comment on lines 47 to 50
if !sub.closed {
close(sub.ch)
sub.closed = true
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs to be atomic or we can have two concurrent closes fail; can you make this an swap/compare with an atomic variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looked like close is never called concurrently; only called by the handler goroutine. ...but in case it is someday...

@vyzo
Copy link
Collaborator

vyzo commented Jun 15, 2021

thank you!

@vyzo vyzo merged commit 55d412e into master Jun 15, 2021
@vyzo vyzo deleted the close-of-closed-channel-425 branch June 15, 2021 10:00
@aschmahmann aschmahmann mentioned this pull request Jul 16, 2021
18 tasks
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.

panic: close of closed channel
2 participants