-
Notifications
You must be signed in to change notification settings - Fork 160
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
Synchronize parallel calls to Conn.Close and Conn.handshake #671
Synchronize parallel calls to Conn.Close and Conn.handshake #671
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #671 +/- ##
==========================================
+ Coverage 80.11% 80.18% +0.07%
==========================================
Files 101 101
Lines 5355 5371 +16
==========================================
+ Hits 4290 4307 +17
+ Misses 695 694 -1
Partials 370 370
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Overall LGTM @Danielius1922! Looks like a different race was found in CI. Once you can get it all to go green happy to test and can fix up any nits myself :) |
Yeah the issue is that Handshakes themselves are serialized using |
@@ -405,7 +411,12 @@ func (c *Conn) Write(p []byte) (int, error) { | |||
// Close closes the connection. | |||
func (c *Conn) Close() error { | |||
err := c.close(true) //nolint:contextcheck | |||
c.handshakeLoopsFinished.Wait() | |||
c.closeLock.Lock() |
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.
poor c.closeLock
gets locked and unlocked thrice in a call to c.Close
(twice in close
+ the call here), I guess I could get the channel in c.close
and return it? Doesn't fit semantically for close
to return the channel, but it is an internal function, so it doesn't matter much.
cancelHandshakeReader := c.cancelHandshakeReader | ||
c.closeLock.Unlock() | ||
|
||
cancelHandshaker() |
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.
@Sean-Der is it important to invoke these cancels at the beginning? if not I could move thes copying to line 1179 (after closeLock gets locked) and the invocations to 1187 (after it gets unlocked)
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.
Tests succeed locally when I do it like that, so maybe the order of calls here isn't imporant, in which case I can do it like that and avoid multiple locking/unlocking of the lock.
9d39efb
to
fc419a4
Compare
Tagged @Danielius1922 I added you to the org! Feel free to make branches and tags. I think the concurrency of |
Description
Reference issue
Fixes #...