From c48a49cd0dcff64cc9476512ac6b86f3c3dfb2f7 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Sat, 22 May 2021 23:05:19 +0200 Subject: [PATCH] dcsctp: Find out quickly if to send FORWARD-TSN There is no need to iterate through all outstanding data chunks to know if a FORWARD-TSN can be sent. As the FORWARD-TSN will just move the cumulative TSN ack, if a chunk is found that is not to be expired, there is no need to continue any further. This makes it much faster to know if to send a FORWARD-TSN when the congestion window is large. Bug: webrtc:12799 Change-Id: I58bce408ae9814c8d3d7bbb480b0037a2cf88dd7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219625 Reviewed-by: Florent Castelli Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/master@{#34176} --- net/dcsctp/tx/retransmission_queue.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/dcsctp/tx/retransmission_queue.cc b/net/dcsctp/tx/retransmission_queue.cc index b841b81b9c..3ed8ea94f0 100644 --- a/net/dcsctp/tx/retransmission_queue.cc +++ b/net/dcsctp/tx/retransmission_queue.cc @@ -724,11 +724,16 @@ void RetransmissionQueue::ExpireChunks(TimeMs now) { // can be expired easily. There is always a risk that a message is expired // that was already received by the peer, but for which there haven't been // a SACK received. But that's acceptable, and handled. - if (item.has_expired(now)) { + if (item.is_abandoned()) { + // Already abandoned. + } else if (item.has_expired(now)) { RTC_DLOG(LS_VERBOSE) << log_prefix_ << "Marking chunk " << *tsn.Wrap() << " and message " << *item.data().message_id << " as expired"; ExpireAllFor(item); + } else { + // A non-expired chunk. No need to iterate any further. + break; } } }