Clear PacketBuffer when full.

BUG=webrtc:5514

Review-Url: https://codereview.webrtc.org/2769963003
Cr-Commit-Position: refs/heads/master@{#17362}
This commit is contained in:
philipel
2017-03-23 06:50:37 -07:00
committed by Commit bot
parent f17fd87d5b
commit c703dc21a6
2 changed files with 4 additions and 3 deletions

View File

@ -148,7 +148,8 @@ void PacketBuffer::Clear() {
bool PacketBuffer::ExpandBufferSize() { bool PacketBuffer::ExpandBufferSize() {
if (size_ == max_size_) { if (size_ == max_size_) {
LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_ LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_
<< "), failed to increase size."; << "), failed to increase size. Clearing PacketBuffer.";
Clear();
return false; return false;
} }

View File

@ -212,7 +212,7 @@ TEST_F(TestPacketBuffer, ExpandBufferOverflow) {
for (int i = 0; i < kMaxSize; ++i) for (int i = 0; i < kMaxSize; ++i)
EXPECT_TRUE(Insert(seq_num + i, kKeyFrame, kFirst, kLast)); EXPECT_TRUE(Insert(seq_num + i, kKeyFrame, kFirst, kLast));
EXPECT_FALSE(Insert(seq_num + kMaxSize + 1, kKeyFrame, kFirst, kLast)); EXPECT_TRUE(Insert(seq_num + kMaxSize + 1, kKeyFrame, kFirst, kLast));
} }
TEST_F(TestPacketBuffer, OnePacketOneFrame) { TEST_F(TestPacketBuffer, OnePacketOneFrame) {
@ -465,7 +465,7 @@ TEST_F(TestPacketBuffer, DontLeakPayloadData) {
EXPECT_FALSE(Insert(1, kKeyFrame, kFirst, kNotLast, 5, data3)); EXPECT_FALSE(Insert(1, kKeyFrame, kFirst, kNotLast, 5, data3));
// Expect to free data4 upon insertion (packet buffer is full). // Expect to free data4 upon insertion (packet buffer is full).
EXPECT_FALSE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4)); EXPECT_TRUE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4));
} }
TEST_F(TestPacketBuffer, ContinuousSeqNumDoubleMarkerBit) { TEST_F(TestPacketBuffer, ContinuousSeqNumDoubleMarkerBit) {