diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index fd320324b8..0929fd9675 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -842,15 +842,16 @@ void RTPSender::UpdateRtpStats(const uint8_t* buffer, const RTPHeader& header, bool is_rtx, bool is_retransmit) { - CriticalSectionScoped lock(statistics_crit_.get()); StreamDataCounters* counters; - uint32_t ssrc; + // Get ssrc before taking statistics_crit_ to avoid possible deadlock. + uint32_t ssrc = SSRC(); + + CriticalSectionScoped lock(statistics_crit_.get()); if (is_rtx) { counters = &rtx_rtp_stats_; ssrc = ssrc_rtx_; } else { counters = &rtp_stats_; - ssrc = ssrc_; } bitrate_sent_.Update(size);