mirror of
https://github.com/minio/minio.git
synced 2025-04-12 07:22:18 -04:00
Fix unresponsiveness of doneCh
due to Sleep call. (#3667)
This commit is contained in:
parent
a9ab01731f
commit
35ca3e5d9b
16
cmd/retry.go
16
cmd/retry.go
@ -91,16 +91,26 @@ func newRetryTimer(unit time.Duration, cap time.Duration, jitter float64, doneCh
|
|||||||
go func() {
|
go func() {
|
||||||
defer close(attemptCh)
|
defer close(attemptCh)
|
||||||
nextBackoff := 0
|
nextBackoff := 0
|
||||||
|
// Channel used to signal after the expiry of backoff wait seconds.
|
||||||
|
var timer *time.Timer
|
||||||
for {
|
for {
|
||||||
select {
|
select { // Attempts starts.
|
||||||
// Attempts starts.
|
|
||||||
case attemptCh <- nextBackoff:
|
case attemptCh <- nextBackoff:
|
||||||
nextBackoff++
|
nextBackoff++
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
// Stop the routine.
|
// Stop the routine.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(exponentialBackoffWait(nextBackoff))
|
timer = time.NewTimer(exponentialBackoffWait(nextBackoff))
|
||||||
|
// wait till next backoff time or till doneCh gets a message.
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
case <-doneCh:
|
||||||
|
// stop the timer and return.
|
||||||
|
timer.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return attemptCh
|
return attemptCh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user