Skip to content

Commit 48078d2

Browse files
committed
Move unlock to defer
1 parent bebc74d commit 48078d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

peer/conn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ func (c *Conn) negotiate() {
297297
c.pendingCandidatesMutex.Unlock()
298298

299299
if !c.offerrer {
300+
// Lock new candidates from processing until we set the local description.
300301
c.pendingCandidatesMutex.Lock()
302+
defer c.pendingCandidatesMutex.Unlock()
301303

302304
answer, err := c.rtc.CreateAnswer(&webrtc.AnswerOptions{})
303305
if err != nil {
@@ -320,7 +322,6 @@ func (c *Conn) negotiate() {
320322

321323
// Wait until the local description is set to flush candidates.
322324
c.flushPendingCandidates()
323-
c.pendingCandidatesMutex.Unlock()
324325
}
325326
}
326327

0 commit comments

Comments
 (0)