summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llwebrtc/llwebrtc.cpp23
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h5
2 files changed, 17 insertions, 11 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index b6b205e858..31bc0cf0c1 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -478,7 +478,7 @@ bool LLWebRTCImpl::terminate()
{
for (auto& connection : connections)
{
- connection->closeOnSignalingThread();
+ connection->closeOnSignalingThread(true);
}
// Destroy the connections here, on the signaling thread, while
// it's still running.
@@ -1137,13 +1137,13 @@ void LLWebRTCPeerConnectionImpl::terminate()
mWebRTCImpl->PostSignalingTask(
[self]()
{
- self->closeOnSignalingThread();
+ self->closeOnSignalingThread(false);
self->mPendingJobs--;
});
}
// Signaling thread only.
-void LLWebRTCPeerConnectionImpl::closeOnSignalingThread()
+void LLWebRTCPeerConnectionImpl::closeOnSignalingThread(bool webrtc_terminate)
{
// Stop issuing stats requests; one may already be in flight, and
// Close() below will flush it.
@@ -1194,13 +1194,16 @@ void LLWebRTCPeerConnectionImpl::closeOnSignalingThread()
observer->OnPeerConnectionClosed();
}
- // Nothing may call back into the viewer past this point. Connections
- // closed while the viewer is still running unset themselves as observers
- // when they're destroyed, but any that are left for llwebrtc::terminate()
- // to close deliberately don't -- they're torn down as soon as it returns,
- // so a late callback would be reaching into freed memory.
- mSignalingObserverList.clear();
- mDataObserverList.clear();
+ if (webrtc_terminate)
+ {
+ // Nothing may call back into the viewer past this point. Connections
+ // closed while the viewer is still running unset themselves as observers
+ // when they're destroyed, but any that are left for llwebrtc::terminate()
+ // to close deliberately don't -- they're torn down as soon as it returns,
+ // so a late callback would be reaching into freed memory.
+ mSignalingObserverList.clear();
+ mDataObserverList.clear();
+ }
}
void LLWebRTCPeerConnectionImpl::setSignalingObserver(LLWebRTCSignalingObserver *observer) { mSignalingObserverList.emplace_back(observer); }
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index ae3a6a4903..c980b28d6e 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -600,10 +600,13 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,
void init(LLWebRTCImpl * webrtc_impl);
// Posts closeOnSignalingThread() and returns immediately.
void terminate();
+
// The actual close. Signaling thread only. Callable directly (via a
// BlockingCall) when the caller needs the connection to be fully closed
// before it continues -- see LLWebRTCImpl::terminate().
- void closeOnSignalingThread();
+ // webrtc_terminate indicates we're shutting down the webrtc library,
+ // if not, we'll be reusing the peer connection for a reconnection
+ void closeOnSignalingThread(bool webrtc_terminate);
virtual void AddRef() const override = 0;
virtual webrtc::RefCountReleaseStatus Release() const override = 0;