Fix sequence-number replay race for padding.

Prevents allocating sequence numbers for packets that go out on the
network even though sending media is disabled.

This race caused a replay of sequence numbers when GetRtpState() on a
stopped stream would not return the last sequence number sent, since the
pacer thread could request and send padding on a later sequence number
before the modules are disconnected from the pacer.

BUG=webrtc:5543
R=stefan@webrtc.org
TEST=Repeating EndToEndTest.RestartingSendStreamPreservesRtpState 1000 times under TSan.

Review URL: https://codereview.webrtc.org/1715703002 .

Cr-Commit-Position: refs/heads/master@{#11685}
This commit is contained in:
Peter Boström 2016-02-19 16:14:37 +01:00
parent 88788adcfd
commit fc968a283c
2 changed files with 5 additions and 6 deletions

View File

@ -556,6 +556,8 @@ int32_t RTPSender::SendOutgoingData(FrameType frame_type,
size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) {
{
rtc::CritScope lock(&send_critsect_);
if (!sending_media_)
return 0;
if ((rtx_ & kRtxRedundantPayloads) == 0)
return 0;
}
@ -618,6 +620,8 @@ size_t RTPSender::SendPadData(size_t bytes,
bool over_rtx;
{
rtc::CritScope lock(&send_critsect_);
if (!sending_media_)
return bytes_sent;
if (!timestamp_provided) {
timestamp = timestamp_;
capture_time_ms = capture_time_ms_;
@ -1011,11 +1015,6 @@ bool RTPSender::IsFecPacket(const uint8_t* buffer,
size_t RTPSender::TimeToSendPadding(size_t bytes) {
if (audio_configured_ || bytes == 0)
return 0;
{
rtc::CritScope lock(&send_critsect_);
if (!sending_media_)
return 0;
}
size_t bytes_sent = TrySendRedundantPayloads(bytes);
if (bytes_sent < bytes)
bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0);

View File

@ -3148,7 +3148,7 @@ void EndToEndTest::TestRtpStatePreservation(bool use_rtx) {
DestroyStreams();
}
TEST_F(EndToEndTest, DISABLED_RestartingSendStreamPreservesRtpState) {
TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpState) {
TestRtpStatePreservation(false);
}