webrtc_m130/net/dcsctp/tx/retransmission_error_counter.cc
Victor Boivie 9680d29e8d 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}
2021-08-31 10:57:48 +00:00

38 lines
1.2 KiB
C++

/*
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "net/dcsctp/tx/retransmission_error_counter.h"
#include "absl/strings/string_view.h"
#include "rtc_base/logging.h"
namespace dcsctp {
bool RetransmissionErrorCounter::Increment(absl::string_view reason) {
++counter_;
if (limit_.has_value() && counter_ > limit_.value()) {
RTC_DLOG(LS_INFO) << log_prefix_ << reason
<< ", too many retransmissions, counter=" << counter_;
return false;
}
RTC_DLOG(LS_VERBOSE) << log_prefix_ << reason << ", new counter=" << counter_
<< ", max=" << limit_.value_or(-1);
return true;
}
void RetransmissionErrorCounter::Clear() {
if (counter_ > 0) {
RTC_DLOG(LS_VERBOSE) << log_prefix_
<< "recovered from counter=" << counter_;
counter_ = 0;
}
}
} // namespace dcsctp