Skip to content

Commit 48cfc63

Browse files
committed
Hold pc.mu while populating local candidates
1 parent 7407903 commit 48cfc63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

peerconnection.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,10 +2104,11 @@ func (pc *PeerConnection) addRTPTransceiver(t *RTPTransceiver) {
21042104
// by the ICEAgent since the offer or answer was created.
21052105
func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
21062106
pc.mu.Lock()
2107+
defer pc.mu.Unlock()
2108+
21072109
localDescription := pc.currentLocalDescription
21082110
iceGather := pc.iceGatherer
21092111
iceGatheringState := pc.ICEGatheringState()
2110-
pc.mu.Unlock()
21112112
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
21122113
}
21132114

@@ -2117,10 +2118,11 @@ func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
21172118
// PeerConnection is in the stable state, the value is null.
21182119
func (pc *PeerConnection) PendingLocalDescription() *SessionDescription {
21192120
pc.mu.Lock()
2121+
defer pc.mu.Unlock()
2122+
21202123
localDescription := pc.pendingLocalDescription
21212124
iceGather := pc.iceGatherer
21222125
iceGatheringState := pc.ICEGatheringState()
2123-
pc.mu.Unlock()
21242126
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
21252127
}
21262128

0 commit comments

Comments
 (0)