dcsctp: Support unlimited max_retransmissions
The restart limit for timers can already be limitless, but the
RetransmissionErrorCounter didn't support this. With this change, the
max_retransmissions and max_init_retransmits can be absl::nullopt to
indicate that there should be infinite retries.
Bug: webrtc:13129
Change-Id: Ia6e91cccbc2e1bb77b3fdd7f37436290adc2f483
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/230701
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34882}
diff --git a/net/dcsctp/timer/timer.cc b/net/dcsctp/timer/timer.cc
index 8f64533..2ad6d74 100644
--- a/net/dcsctp/timer/timer.cc
+++ b/net/dcsctp/timer/timer.cc
@@ -93,8 +93,8 @@
if (is_running_ && generation == generation_) {
++expiration_count_;
is_running_ = false;
- if (options_.max_restarts < 0 ||
- expiration_count_ <= options_.max_restarts) {
+ if (!options_.max_restarts.has_value() ||
+ expiration_count_ <= *options_.max_restarts) {
// The timer should still be running after this triggers. Start a new
// timer. Note that it might be very quickly restarted again, if the
// `on_expired_` callback returns a new duration.