From 43f8fe339feb4cfa369c6c2b618f2d7c1692ae86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 17 Apr 2023 22:38:03 +0200 Subject: [PATCH] webrtc peer do not set nil conn. --- internal/webrtc/manager.go | 2 +- internal/webrtc/peer.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index 25b9de89..31c439aa 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -487,7 +487,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int, session.SetWebRTCConnected(peer, true) case webrtc.PeerConnectionStateDisconnected, webrtc.PeerConnectionStateFailed: - connection.Close() + peer.Destroy() case webrtc.PeerConnectionStateClosed: // ensure we only run this once once.Do(func() { diff --git a/internal/webrtc/peer.go b/internal/webrtc/peer.go index 4e26f5d6..91b405c9 100644 --- a/internal/webrtc/peer.go +++ b/internal/webrtc/peer.go @@ -106,11 +106,8 @@ func (peer *WebRTCPeerCtx) Destroy() { peer.mu.Lock() defer peer.mu.Unlock() - if peer.connection != nil { - err := peer.connection.Close() - peer.logger.Err(err).Msg("peer connection destroyed") - peer.connection = nil - } + err := peer.connection.Close() + peer.logger.Err(err).Msg("peer connection destroyed") } func (peer *WebRTCPeerCtx) estimatorReader() {