File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,27 @@ namespace ix
14
14
uint32_t maxWaitBetweenReconnectionRetries,
15
15
uint32_t minWaitBetweenReconnectionRetries)
16
16
{
17
- uint32_t waitTime = (retryCount < 26 ) ? (std::pow (2 , retryCount) * 100 ) : 0 ;
17
+ // It's easy with a power function to go beyond 2^32, and then
18
+ // have unexpected results, so prepare for that
19
+ const uint32_t maxRetryCountWithoutOverflow = 26 ;
20
+
21
+ uint32_t waitTime = 0 ;
22
+ if (retryCount < maxRetryCountWithoutOverflow)
23
+ {
24
+ waitTime = std::pow (2 , retryCount) * 100 ;
25
+ }
18
26
19
27
if (waitTime < minWaitBetweenReconnectionRetries)
20
28
{
21
29
waitTime = minWaitBetweenReconnectionRetries;
22
30
}
23
31
24
- if (waitTime > maxWaitBetweenReconnectionRetries || waitTime == 0 )
32
+ if (waitTime > maxWaitBetweenReconnectionRetries)
33
+ {
34
+ waitTime = maxWaitBetweenReconnectionRetries;
35
+ }
36
+
37
+ if (retryCount >= maxRetryCountWithoutOverflow)
25
38
{
26
39
waitTime = maxWaitBetweenReconnectionRetries;
27
40
}
You can’t perform that action at this time.
0 commit comments