Skip to content

Commit

Permalink
Merge 65221e6 into adb73d5
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Sep 21, 2018
2 parents adb73d5 + 65221e6 commit 698b6ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ func (b *backOffContext) Context() context.Context {

func (b *backOffContext) NextBackOff() time.Duration {
select {
case <-b.Context().Done():
case <-b.ctx.Done():
return Stop
default:
return b.BackOff.NextBackOff()
}
next := b.BackOff.NextBackOff()
if deadline, ok := b.ctx.Deadline(); ok && deadline.Sub(time.Now()) < next {
return Stop
}
return next
}
2 changes: 1 addition & 1 deletion retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func RetryNotify(operation Operation, b BackOff, notify Notify) error {
return permanent.Err
}

if next = b.NextBackOff(); next == Stop {
if next = cb.NextBackOff(); next == Stop {
return err
}

Expand Down

0 comments on commit 698b6ea

Please sign in to comment.