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

Avoid double-closing channels #5

Closed
wants to merge 3 commits into from

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Jul 28, 2017

This was causing us to:

  1. Panic.
  2. Try to close the stream.
  3. Try to re-take the lock while closing the stream (and deadlock).

fixes ipfs/kubo#4038

This was causing us to:

1. Panic.
2. Try to close the stream.
3. Try to re-take the lock while closing the stream (and deadlock).

fixes ipfs/kubo#4038
@Stebalien
Copy link
Member Author

I'm guessing this happens when the remote side closes the stream twice at the same time (there's a race where we can send a close twice).

stream.go Outdated
@@ -136,6 +134,8 @@ func (s *Stream) Close() error {
s.closedLocal = true
s.clLock.Unlock()

err := s.mp.sendMsg((s.id<<3)|Close, nil, time.Time{})

Copy link
Member Author

Choose a reason for hiding this comment

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

Was there a reason to do this in the other order? I see a commit message talking about a "write-close" edge case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is a problem. We can end up closing the connection before all closes are sent.

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.

more insight into t0130 random sharness failures
1 participant