Skip to content

Commit 77cd515

Browse files
edgarsendernetwez
authored andcommitted
Avoid overflow when calculating delay
1 parent 6193331 commit 77cd515

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

crates/kumod/src/queue/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ impl QueueConfig {
156156
}
157157

158158
pub fn delay_for_attempt(&self, attempt: u16) -> chrono::Duration {
159-
let delay = self.retry_interval.as_secs() * 2u64.saturating_pow(attempt as u32);
159+
let delay = self
160+
.retry_interval
161+
.as_secs()
162+
.saturating_mul(2u64.saturating_pow(attempt as u32));
160163

161164
let delay = match self.max_retry_interval.map(|d| d.as_secs()) {
162165
None => delay,

0 commit comments

Comments
 (0)