mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-25 16:33:39 +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{})
|
pcConnected := make(chan struct{})
|
||||||
pcDisconnected := make(chan struct{})
|
pcDisconnected := make(chan struct{})
|
||||||
pcClosed := make(chan struct{})
|
pcClosed := make(chan struct{})
|
||||||
|
var stateChangeMutex sync.Mutex
|
||||||
|
|
||||||
pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
|
||||||
|
stateChangeMutex.Lock()
|
||||||
|
defer stateChangeMutex.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-pcClosed:
|
case <-pcClosed:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user