Race condition in RTPSender::UpdateRtpStats

The ssrc should not be access directly from the ssrc_ field, without
holding the send_critsect_ lock. A better way is to just use the SSRC()
getter method.

BUG=
R=pbos@webrtc.org, stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/7539006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5439 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
sprang@webrtc.org 2014-01-27 13:20:36 +00:00
parent d9b9560ee5
commit 5314e85926

View File

@ -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);