-
Notifications
You must be signed in to change notification settings - Fork 582
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: Lock when obtaining a peer connection answer<->offer #24
Conversation
This fixes a race in the peerbroker package where ICE candidates could be added before the connection was negotiated. This would result in the connection failing.
peerbroker/listen.go
Outdated
@@ -184,7 +184,7 @@ func (b *peerBrokerService) NegotiateConnection(stream proto.DRPCPeerBroker_Nego | |||
Candidate: clientToServerMessage.GetIceCandidate(), | |||
}) | |||
if err != nil { | |||
return peerConn.CloseWithError(xerrors.Errorf("add remote candidate: %w", err)) | |||
return peerConn.CloseWithError(xerrors.Errorf("add remote candidate: %+v: %w", clientToServerMessage.GetIceCandidate(), err)) |
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.
Thanks for adding this extra logging!
Codecov Report
@@ Coverage Diff @@
## main #24 +/- ##
==========================================
+ Coverage 70.61% 70.91% +0.29%
==========================================
Files 18 18
Lines 1130 1138 +8
==========================================
+ Hits 798 807 +9
+ Misses 262 261 -1
Partials 70 70
Continue to review full report at Codecov.
|
@@ -84,7 +84,7 @@ func Dial(stream proto.DRPCPeerBroker_NegotiateConnectionClient, iceServers []we | |||
for { | |||
serverToClientMessage, err := stream.Recv() | |||
if err != nil { | |||
_ = peerConn.CloseWithError(err) | |||
_ = peerConn.CloseWithError(xerrors.Errorf("recv: %w", err)) |
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.
Glad to have more info when this comes up!
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.
Looks reasonable to me - but I'm not an expert on this. Figured it had to be some tricky race condition!
This fixes a race in the peerbroker package where ICE candidates could be added before the connection was negotiated. This would result in the connection failing.