Race in StreamStatisticianImpl::GetStatistics vs. ::IncomingPacket

StreamStatisticianImpl.ssrc_ is protected by stream_lock_, should
  be cached while holding lock to avoid race condition.

  Also, rtp_callback_ do not need to be called in GetStatistics() at all

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

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5435 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
sprang@webrtc.org 2014-01-27 10:42:48 +00:00
parent 99eab02fb1
commit c00adbed73
2 changed files with 6 additions and 5 deletions

View File

@ -180,6 +180,7 @@ void StreamStatisticianImpl::SetMaxReorderingThreshold(
bool StreamStatisticianImpl::GetStatistics(RtcpStatistics* statistics,
bool reset) {
uint32_t ssrc;
{
CriticalSectionScoped cs(stream_lock_.get());
if (received_seq_first_ == 0 && receive_counters_.bytes == 0) {
@ -197,16 +198,16 @@ bool StreamStatisticianImpl::GetStatistics(RtcpStatistics* statistics,
return true;
}
*statistics = CalculateStatistics();
*statistics = CalculateRtcpStatistics();
ssrc = ssrc_;
}
rtcp_callback_->StatisticsUpdated(*statistics, ssrc_);
rtp_callback_->DataCountersUpdated(receive_counters_, ssrc_);
rtcp_callback_->StatisticsUpdated(*statistics, ssrc);
return true;
}
RtcpStatistics StreamStatisticianImpl::CalculateStatistics() {
RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() {
RtcpStatistics stats;
if (last_report_inorder_packets_ == 0) {

View File

@ -49,7 +49,7 @@ class StreamStatisticianImpl : public StreamStatistician {
private:
bool InOrderPacketInternal(uint16_t sequence_number) const;
RtcpStatistics CalculateStatistics();
RtcpStatistics CalculateRtcpStatistics();
void UpdateJitter(const RTPHeader& header,
uint32_t receive_time_secs,
uint32_t receive_time_frac);