-
Notifications
You must be signed in to change notification settings - Fork 206
Fix panic in multiListener #329
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
Conversation
|
Welcome @denpeshkov! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go ahead and squash commits once the comment is addressed, then this lgtm
If Close() is called concurrently, both goroutines could pass the select’s default case before either of them executes close(), resulting in the channel being closed twice
961d3be
to
14892a7
Compare
lgtm, ack from network reviewer would be great as well (@aojea?) |
/lgtm Thanks , good one |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, denpeshkov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Wouldn't it be better to use a sync.Once to ensure all callers see the effects of a concurrent Close if Close returns for them? i.e. a caller may rely on a listener actually being closed vs being in the process of being closed when Close returns. The current behavior does not match the doc since it might not wait for the goroutines to exit: Lines 151 to 152 in 0af2bda
I can open a PR if the above makes sense. |
I do not completely follow, but the behavior that we have now IIUIC is:
Is your point about the second call to Close() , if the fist Close() didn't finish yet, it should also wait? |
Yes. Today, unless you know you are the first/only caller, you cannot rely on |
Also, I'm not sure I understand why returning an error on double close is important but at the same time we discard all the actual errors from listeners/connections that we close. |
I honestly can;t remember, and do not have much time these days to dig deeper, I assume that if a listener is close we do not care about bubbling up the error since it is already close and that is the intention. The best next step should be to ensure we match the behavior of the existing standard listener , since the goal was to make a compatible one for dual stack use cases, see the golang original issue golang/go#9334 that is still open |
Opened #331. |
If
Close()
is called concurrently, both goroutines could pass theselect
’s default case before either of them executesclose(ml.stopCh)
, resulting in the channel being closed twice/kind bug