Skip to content

Commit b73358f

Browse files
dam5hhrxi
authored andcommitted
address overflow on bitshift in backoff_time
Fixes #29.
1 parent 99a26ba commit b73358f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,8 @@ impl BackgroundTask {
490490
})
491491
}
492492
fn backoff_time(&self) -> (bool, Duration) {
493-
let backoff_count: u64 = self.backoff_count.into();
494-
let backoff_time = if backoff_count >= 1 {
495-
Duration::from_millis(500 * (1 << (backoff_count - 1)))
493+
let backoff_time = if self.backoff_count >= 1 {
494+
Duration::from_millis(500u64.checked_shl(self.backoff_count - 1).unwrap_or(u64::MAX))
496495
} else {
497496
Duration::from_millis(0)
498497
};

0 commit comments

Comments
 (0)