From f8f9c4fd4e958cdebe1e0ffab38d979b330012a4 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 4 Apr 2023 14:04:13 -0700 Subject: [PATCH] Don't unregister an observer while inside an observer callback. PiperOrigin-RevId: 521860015 --- connections/implementation/mediums/webrtc/webrtc_socket_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc index 7cabc69a..e4a75f7f 100644 --- a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc +++ b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc @@ -67,6 +67,7 @@ WebRtcSocket::WebRtcSocket( WebRtcSocket::~WebRtcSocket() { NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ << ") this: " << this; + data_channel_->UnregisterObserver(); Close(); NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ << ") this: " << this << " done"; @@ -108,7 +109,6 @@ void WebRtcSocket::OnStateChange() { NEARBY_LOG( ERROR, "WebRtcSocket::OnStateChange() unregistering data channel observer."); - data_channel_->UnregisterObserver(); // This will trigger a destruction of the owning connection flow // We implicitly depend on the |socket_listener_| to offload from // the signaling thread so it does not get blocked.