Skip to content

Commit c4e477a

Browse files
committed
Hold pc.mu while populating local candidates
1 parent 12cb8ab commit c4e477a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

peerconnection.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -2114,10 +2114,11 @@ func (pc *PeerConnection) addRTPTransceiver(t *RTPTransceiver) {
21142114
// by the ICEAgent since the offer or answer was created.
21152115
func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
21162116
pc.mu.Lock()
2117+
defer pc.mu.Unlock()
2118+
21172119
localDescription := pc.currentLocalDescription
21182120
iceGather := pc.iceGatherer
21192121
iceGatheringState := pc.ICEGatheringState()
2120-
pc.mu.Unlock()
21212122
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
21222123
}
21232124

@@ -2127,10 +2128,11 @@ func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
21272128
// PeerConnection is in the stable state, the value is null.
21282129
func (pc *PeerConnection) PendingLocalDescription() *SessionDescription {
21292130
pc.mu.Lock()
2131+
defer pc.mu.Unlock()
2132+
21302133
localDescription := pc.pendingLocalDescription
21312134
iceGather := pc.iceGatherer
21322135
iceGatheringState := pc.ICEGatheringState()
2133-
pc.mu.Unlock()
21342136
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
21352137
}
21362138

0 commit comments

Comments
 (0)