Race condition in RTPSender

RTPSender::sending_media_ should be guarded by send_critsect_. Fix this
in GetSendSideDelay, SendPadData and TimeToSendPadding.
Also add appropriate thread annotations.

BUG=3029
R=stefan@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5697 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
sprang@webrtc.org 2014-03-13 15:12:37 +00:00
parent 41689018a0
commit 5a320fb06f
2 changed files with 9 additions and 6 deletions

View File

@ -157,10 +157,12 @@ uint32_t RTPSender::NackOverheadRate() const {
bool RTPSender::GetSendSideDelay(int* avg_send_delay_ms,
int* max_send_delay_ms) const {
if (!SendingMedia())
return false;
CriticalSectionScoped cs(statistics_crit_.get());
SendDelayMap::const_iterator it = send_delays_.upper_bound(
clock_->TimeInMilliseconds() - kSendSideDelayWindowMs);
if (!sending_media_ || it == send_delays_.end())
if (it == send_delays_.end())
return false;
int num_delays = 0;
for (; it != send_delays_.end(); ++it) {
@ -528,7 +530,7 @@ int RTPSender::SendPadData(int payload_type, uint32_t timestamp,
StorageType store, bool force_full_size_packets,
bool only_pad_after_markerbit) {
// Drop this packet if we're not sending media packets.
if (!sending_media_) {
if (!SendingMedia()) {
return bytes;
}
int padding_bytes_in_packet = 0;
@ -888,14 +890,14 @@ bool RTPSender::IsFecPacket(const uint8_t* buffer,
}
int RTPSender::TimeToSendPadding(int bytes) {
if (!sending_media_) {
return 0;
}
int payload_type;
int64_t capture_time_ms;
uint32_t timestamp;
{
CriticalSectionScoped cs(send_critsect_);
if (!sending_media_) {
return 0;
}
payload_type = ((rtx_ & kRtxRedundantPayloads) > 0) ? payload_type_rtx_ :
payload_type_;
timestamp = timestamp_;

View File

@ -25,6 +25,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
#include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
#include "webrtc/modules/rtp_rtcp/source/video_codec_information.h"
#include "webrtc/system_wrappers/interface/thread_annotations.h"
#define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1.
@ -336,7 +337,7 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
CriticalSectionWrapper *send_critsect_;
Transport *transport_;
bool sending_media_;
bool sending_media_ GUARDED_BY(send_critsect_);
uint16_t max_payload_length_;
uint16_t target_send_bitrate_;