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 for whandshake #16

Closed
wants to merge 2 commits into from

Conversation

JustinDrake
Copy link

See race condition reported at ipfs/kubo#4105

Reuse whlock for whandshake

See race condition reported at ipfs/kubo#4105

Reuse `whlock` for `whandshake`
@@ -119,6 +119,9 @@ func (l *lazyConn) writeHandshake() error {
}

func (l *lazyConn) Write(b []byte) (int, error) {
l.whlock.Lock()
defer l.whlock.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

This won't work as writeHandshake takes the same lock.

Copy link
Author

Choose a reason for hiding this comment

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

My bad. I've removed the lock in writeHandshake and added it when calling it in Read.

@coveralls
Copy link

coveralls commented Jul 29, 2017

Coverage Status

Coverage increased (+0.2%) to 79.657% when pulling adda1dd on JustinDrake:patch-1 into b8f1996 on multiformats:master.

@Kubuxu
Copy link
Member

Kubuxu commented Jul 29, 2017

I will dig into that concurrency here to make sure it is correct. I hope you won't mind if I come up with alternate solution.

@JustinDrake
Copy link
Author

No problem @Kubuxu. Thanks for looking into it 👍

@Stebalien
Copy link
Member

Fix in #21.

@Stebalien Stebalien closed this Feb 21, 2018
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.

4 participants