Destroy stats collectors before destroying BaseChannels

Bug: None
Change-Id: I4b54cc0a3cf694f536ba1775d55dab58fd0df536
Reviewed-on: https://webrtc-review.googlesource.com/33561
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21308}
This commit is contained in:
Steve Anton
2017-12-15 11:20:13 -08:00
committed by Commit Bot
parent e7781b3e2a
commit 8af2186ad5
2 changed files with 17 additions and 11 deletions

View File

@ -726,16 +726,23 @@ PeerConnection::~PeerConnection() {
TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection");
RTC_DCHECK_RUN_ON(signaling_thread());
StopAndDestroyChannels();
// Need to stop transceivers before destroying the stats collector because
// AudioRtpSender has a reference to the StatsCollector it will update when
// stopping.
for (auto transceiver : transceivers_) {
transceiver->Stop();
}
// Destroy stats after stopping all transceivers because the senders/receivers
// will update the stats collector before stopping.
stats_.reset(nullptr);
if (stats_collector_) {
stats_collector_->WaitForPendingRequest();
stats_collector_ = nullptr;
}
// Don't destroy BaseChannels until after stats has been cleaned up so that
// the last stats request can still read from the channels.
DestroyAllChannels();
RTC_LOG(LS_INFO) << "Session: " << session_id() << " is destroyed.";
webrtc_session_desc_factory_.reset();
@ -753,10 +760,7 @@ PeerConnection::~PeerConnection() {
});
}
void PeerConnection::StopAndDestroyChannels() {
for (auto transceiver : transceivers_) {
transceiver->Stop();
}
void PeerConnection::DestroyAllChannels() {
// Destroy video channels first since they may have a pointer to a voice
// channel.
for (auto transceiver : transceivers_) {
@ -2345,7 +2349,10 @@ void PeerConnection::Close() {
ChangeSignalingState(PeerConnectionInterface::kClosed);
StopAndDestroyChannels();
for (auto transceiver : transceivers_) {
transceiver->Stop();
}
DestroyAllChannels();
network_thread()->Invoke<void>(
RTC_FROM_HERE,

View File

@ -687,9 +687,8 @@ class PeerConnection : public PeerConnectionInterface,
// RtpDataChannel.
void EnableSending();
// Stops all RtpTransceivers, destroys all BaseChannels and destroys the
// SCTP data channel.
void StopAndDestroyChannels();
// Destroys all BaseChannels and destroys the SCTP data channel, if present.
void DestroyAllChannels();
// Returns the media index for a local ice candidate given the content name.
// Returns false if the local session description does not have a media