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: Lock when obtaining a peer connection answer<->offer #24

Merged
merged 3 commits into from
Jan 13, 2022

Conversation

kylecarbs
Copy link
Member

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.

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.
@kylecarbs kylecarbs self-assigned this Jan 13, 2022
@@ -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))
Copy link
Contributor

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
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #24 (7923caa) into main (550c4fb) will increase coverage by 0.29%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
macos-latest 62.42% <100.00%> (+0.71%) ⬆️
ubuntu-latest 70.65% <100.00%> (+0.38%) ⬆️
windows-latest 62.32% <100.00%> (+0.51%) ⬆️
Impacted Files Coverage Δ
peer/conn.go 75.53% <100.00%> (+0.92%) ⬆️
peerbroker/dial.go 72.72% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 550c4fb...7923caa. Read the comment docs.

@@ -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))
Copy link
Contributor

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!

Copy link
Contributor

@bryphe-coder bryphe-coder left a 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!

@kylecarbs kylecarbs merged commit 4308f16 into main Jan 13, 2022
@kylecarbs kylecarbs deleted the peerflakey branch January 13, 2022 21:02
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.

None yet

2 participants