dcsctp: Add test case for pending paused streams

This use case was missing test coverage and sufficient comments in the
code.

Bug: None
Change-Id: I95b54a64f714b68a347fdbeef79eb38e715adbc3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257166
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36393}
This commit is contained in:
Victor Boivie
2022-03-18 09:16:35 +01:00
committed by WebRTC LUCI CQ
parent b6c58559a7
commit 0cfaa610ca
2 changed files with 33 additions and 1 deletions

View File

@ -44,7 +44,9 @@ bool RRSendQueue::OutgoingStream::HasDataToSend(TimeMs now) {
while (!items_.empty()) {
RRSendQueue::OutgoingStream::Item& item = items_.front();
if (item.message_id.has_value()) {
// Already partially sent messages can always continue to be sent.
// Already partially sent messages can always continue to be sent. This
// ensures e.g. that paused streams with partially sent messages get to
// send the partial message in full before resetting.
return true;
}

View File

@ -323,6 +323,36 @@ TEST_F(RRSendQueueTest, EnqueuedItemsArePausedDuringStreamReset) {
EXPECT_EQ(buf_.total_buffered_amount(), 0u);
}
TEST_F(RRSendQueueTest, PausedStreamsStillSendPartialMessagesUntilEnd) {
constexpr size_t kPayloadSize = 100;
constexpr size_t kFragmentSize = 50;
std::vector<uint8_t> payload(kPayloadSize);
buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload));
buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload));
absl::optional<SendQueue::DataToSend> chunk_one =
buf_.Produce(kNow, kFragmentSize);
ASSERT_TRUE(chunk_one.has_value());
EXPECT_EQ(chunk_one->data.stream_id, kStreamID);
EXPECT_EQ(buf_.total_buffered_amount(), 2 * kPayloadSize - kFragmentSize);
// This will stop the second message from being sent.
StreamID stream_ids[] = {StreamID(1)};
buf_.PrepareResetStreams(stream_ids);
EXPECT_EQ(buf_.total_buffered_amount(), 1 * kPayloadSize - kFragmentSize);
// Should still produce fragments until end of message.
absl::optional<SendQueue::DataToSend> chunk_two =
buf_.Produce(kNow, kFragmentSize);
ASSERT_TRUE(chunk_two.has_value());
EXPECT_EQ(chunk_two->data.stream_id, kStreamID);
EXPECT_EQ(buf_.total_buffered_amount(), 0ul);
// But shouldn't produce any more messages as the stream is paused.
EXPECT_FALSE(buf_.Produce(kNow, kFragmentSize).has_value());
}
TEST_F(RRSendQueueTest, CommittingResetsSSN) {
std::vector<uint8_t> payload(50);