Skip to content

Commit

Permalink
Hold pc.mu while populating local candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniels committed Jul 19, 2024
1 parent b874788 commit 8bcaf6f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2114,10 +2114,11 @@ func (pc *PeerConnection) addRTPTransceiver(t *RTPTransceiver) {
// by the ICEAgent since the offer or answer was created.
func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
pc.mu.Lock()
defer pc.mu.Unlock()

localDescription := pc.currentLocalDescription
iceGather := pc.iceGatherer
iceGatheringState := pc.ICEGatheringState()
pc.mu.Unlock()
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
}

Expand All @@ -2127,10 +2128,11 @@ func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription {
// PeerConnection is in the stable state, the value is null.
func (pc *PeerConnection) PendingLocalDescription() *SessionDescription {
pc.mu.Lock()
defer pc.mu.Unlock()

localDescription := pc.pendingLocalDescription
iceGather := pc.iceGatherer
iceGatheringState := pc.ICEGatheringState()
pc.mu.Unlock()
return populateLocalCandidates(localDescription, iceGather, iceGatheringState)
}

Expand Down

0 comments on commit 8bcaf6f

Please sign in to comment.