mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Close webrtc socket before closing the PeerConnection.
PiperOrigin-RevId: 522140908
This commit is contained in:
@@ -495,12 +495,17 @@ bool ConnectionFlow::CloseOnSignalingThread() {
|
||||
return false;
|
||||
}
|
||||
state_ = State::kEnded;
|
||||
// Close the socket wrapper before terminating the PeerConnection
|
||||
// since the teardown process of the PC may close threads that are
|
||||
// otherwise depended upon by objects kept alive by the socket_wrapper.
|
||||
if (socket_wrapper_.IsValid()) socket_wrapper_.Close();
|
||||
|
||||
// This prevents other tasks from queuing on the signaling thread for this
|
||||
// object.
|
||||
auto pc = GetAndResetPeerConnection();
|
||||
|
||||
NEARBY_LOG(INFO, "Closing WebRTC peer connection.");
|
||||
// NOTE: Closing the peer conection will close the data channel and thus the
|
||||
// NOTE: Closing the peer connection will close the data channel and thus the
|
||||
// socket implicitly.
|
||||
if (pc) pc->Close();
|
||||
NEARBY_LOG(INFO, "Closed WebRTC peer connection.");
|
||||
|
||||
@@ -67,8 +67,12 @@ WebRtcSocket::WebRtcSocket(
|
||||
WebRtcSocket::~WebRtcSocket() {
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
<< ") this: " << this;
|
||||
data_channel_->UnregisterObserver();
|
||||
Close();
|
||||
|
||||
if (!IsClosed()) {
|
||||
data_channel_->UnregisterObserver();
|
||||
Close();
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
<< ") this: " << this << " done";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user