mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-23 23:22:26 +00:00
OnConnectionStateChange of pion/webrtc is not thread safe. Add a mutex to make it thread safe.
This commit is contained in:
parent
8ffdd9c80e
commit
64b8fd3554
@ -345,8 +345,12 @@ func (c *webRTCConn) runInner(ctx context.Context) error {
|
||||
pcConnected := make(chan struct{})
|
||||
pcDisconnected := make(chan struct{})
|
||||
pcClosed := make(chan struct{})
|
||||
var stateChangeMutex sync.Mutex
|
||||
|
||||
pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||
stateChangeMutex.Lock()
|
||||
defer stateChangeMutex.Unlock()
|
||||
|
||||
select {
|
||||
case <-pcClosed:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user