Skip to content

Commit 6f7e3af

Browse files
committed
Try locking only on remote
1 parent de209c7 commit 6f7e3af

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

peer/conn.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,14 @@ func (c *Conn) negotiate() {
287287
c.opts.Logger.Debug(context.Background(), "setting remote description")
288288
err := c.rtc.SetRemoteDescription(remoteDescription)
289289
if err != nil {
290-
c.pendingCandidatesMutex.Unlock()
291290
_ = c.CloseWithError(xerrors.Errorf("set remote description (closed %v): %w", c.isClosed(), err))
292291
return
293292
}
294-
295-
if c.offerrer {
296-
// ICE candidates reset when an offer/answer is set for the first
297-
// time. If candidates flush before this point, a connection could fail.
298-
err = c.flushPendingCandidates()
299-
if err != nil {
300-
_ = c.CloseWithError(xerrors.Errorf("flush pending candidates: %w", err))
301-
}
293+
// ICE candidates reset when an offer/answer is set for the first
294+
// time. If candidates flush before this point, a connection could fail.
295+
err = c.flushPendingCandidates()
296+
if err != nil {
297+
_ = c.CloseWithError(xerrors.Errorf("flush pending candidates: %w", err))
302298
}
303299

304300
if !c.offerrer {
@@ -321,12 +317,6 @@ func (c *Conn) negotiate() {
321317
return
322318
case c.localSessionDescriptionChannel <- answer:
323319
}
324-
325-
// Wait until the local description is set to flush candidates.
326-
err = c.flushPendingCandidates()
327-
if err != nil {
328-
_ = c.CloseWithError(xerrors.Errorf("flush pending candidates: %w", err))
329-
}
330320
}
331321
}
332322

0 commit comments

Comments
 (0)