Skip to content

Commit b9c21cd

Browse files
committed
TimedAttempt: fix rollover
1 parent 12e9def commit b9c21cd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utility/time/TimedAttempt.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ unsigned long TimedAttempt::retry() {
5454
unsigned long TimedAttempt::reload() {
5555
unsigned long retryDelay = (1 << _retryCount) * _minDelay;
5656
_retryDelay = min(retryDelay, _maxDelay);
57-
_nextRetryTick = millis() + _retryDelay;
57+
_retryTick = millis();
5858
return _retryDelay;
5959
}
6060

@@ -67,7 +67,7 @@ bool TimedAttempt::isRetry() {
6767
}
6868

6969
bool TimedAttempt::isExpired() {
70-
return millis() > _nextRetryTick;
70+
return millis() - _retryTick > _retryDelay;
7171
}
7272

7373
unsigned int TimedAttempt::getRetryCount() {

src/utility/time/TimedAttempt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TimedAttempt {
3434
private:
3535
unsigned long _minDelay;
3636
unsigned long _maxDelay;
37-
unsigned long _nextRetryTick;
37+
unsigned long _retryTick;
3838
unsigned long _retryDelay;
3939
unsigned int _retryCount;
4040
};

0 commit comments

Comments
 (0)