Fix potential deadlock in VideoAnalyzer

Bug: webrtc:11809
Change-Id: I9b037f7bc06ff8e5b5b6abf3467d7a3825c212e8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180520
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31807}
This commit is contained in:
Ilya Nikolaevskiy 2020-07-29 16:20:13 +00:00 committed by Commit Bot
parent 81d2bbf96e
commit 3ea3e0c345

View File

@ -456,9 +456,15 @@ bool VideoAnalyzer::IsInSelectedSpatialAndTemporalLayer(
}
void VideoAnalyzer::PollStats() {
// Do not grab |comparison_lock_|, before |GetStats()| completes.
// Otherwise a deadlock may occur:
// 1) |comparison_lock_| is acquired after |lock_|
// 2) |lock_| is acquired after internal pacer lock in SendRtp()
// 3) internal pacer lock is acquired by GetStats().
Call::Stats call_stats = call_->GetStats();
MutexLock lock(&comparison_lock_);
Call::Stats call_stats = call_->GetStats();
send_bandwidth_bps_.AddSample(call_stats.send_bandwidth_bps);
VideoSendStream::Stats send_stats = send_stream_->GetStats();