mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-23 03:33:15 +00:00
Compute the next backoff value before using it
This commit is contained in:
@@ -108,16 +108,17 @@ func (storage *GCDStorage) shouldRetry(threadIndex int, err error) (bool, error)
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
delay := storage.backoffs[threadIndex]*rand.Float64() + storage.backoffs[threadIndex]*rand.Float64()
|
|
||||||
LOG_INFO("GCD_RETRY", "Thread: %03d. Message: %s. Retrying after %.2f seconds. current backoff: %.2f. Number of retries: %d", threadIndex, message, delay, storage.backoffs[threadIndex], storage.backoffsRetries[threadIndex])
|
|
||||||
time.Sleep(time.Duration(delay * float64(time.Second)))
|
|
||||||
|
|
||||||
if storage.backoffs[threadIndex] < LIMIT_BACKOFF_TIME {
|
if storage.backoffs[threadIndex] < LIMIT_BACKOFF_TIME {
|
||||||
storage.backoffs[threadIndex] *= 2.0
|
storage.backoffs[threadIndex] *= 2.0
|
||||||
} else {
|
} else {
|
||||||
storage.backoffs[threadIndex] = LIMIT_BACKOFF_TIME
|
storage.backoffs[threadIndex] = LIMIT_BACKOFF_TIME
|
||||||
storage.backoffsRetries[threadIndex] += 1
|
storage.backoffsRetries[threadIndex] += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay := storage.backoffs[threadIndex]*rand.Float64() + storage.backoffs[threadIndex]*rand.Float64()
|
||||||
|
LOG_INFO("GCD_RETRY", "Thread: %03d. Message: %s. Retrying after %.2f seconds. Current backoff: %.2f. Number of retries: %d", threadIndex, message, delay, storage.backoffs[threadIndex], storage.backoffsRetries[threadIndex])
|
||||||
|
time.Sleep(time.Duration(delay * float64(time.Second)))
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user