Avoid race in Call destructor

Don't update histograms until we're sure process threads won't call into
the instance being destructed, trying to update stats.

BUG=webrtc:6103

Review-Url: https://codereview.webrtc.org/2151433002
Cr-Commit-Position: refs/heads/master@{#13461}
This commit is contained in:
sprang 2016-07-13 06:37:09 -07:00 committed by Commit bot
parent f93be584f7
commit 6d6122b461

View File

@ -265,8 +265,6 @@ Call::Call(const Call::Config& config)
Call::~Call() {
RTC_DCHECK(!remb_.InUse());
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
UpdateSendHistograms();
UpdateReceiveHistograms();
RTC_CHECK(audio_send_ssrcs_.empty());
RTC_CHECK(video_send_ssrcs_.empty());
RTC_CHECK(video_send_streams_.empty());
@ -282,6 +280,12 @@ Call::~Call() {
module_process_thread_->DeRegisterModule(call_stats_.get());
module_process_thread_->Stop();
call_stats_->DeregisterStatsObserver(congestion_controller_.get());
// Only update histograms after process threads have been shut down, so that
// they won't try to concurrently update stats.
UpdateSendHistograms();
UpdateReceiveHistograms();
Trace::ReturnTrace();
}