combine retry deciders in better way

This fixes the problem that, if forwardRetry was checked for the first 5
and decided to retry, the 6th would go to configuredRetry which would
see the counter was 6 and so wait retry-delay*2^5 seconds (default 32).

Now, it waits for retry-delay before each retry, even when forwardRetry
initiated the retry.
This commit is contained in:
Joey Hess 2020-09-04 12:47:53 -04:00
parent 1d244bafbd
commit 1a42b2c5a3
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -196,10 +196,13 @@ type NumRetries = Integer
type RetryDecider = NumRetries -> TransferInfo -> TransferInfo -> Annex Bool
{- The first RetryDecider will be checked first; only if it says not to
- retry will the second one be checked. -}
{- Both retry deciders are checked together, so if one chooses to delay,
- it will always take effect. -}
combineRetryDeciders :: RetryDecider -> RetryDecider -> RetryDecider
combineRetryDeciders a b = \n old new -> a n old new <||> b n old new
combineRetryDeciders a b = \n old new -> do
ar <- a n old new
br <- b n old new
return (ar || br)
noRetry :: RetryDecider
noRetry _ _ _ = pure False
@ -225,7 +228,7 @@ forwardRetry = \numretries old new -> pure $ and
{- Retries a number of times with growing delays in between when enabled
- by git configuration. -}
configuredRetry :: RetryDecider
configuredRetry numretries old new = do
configuredRetry numretries _old new = do
(maxretries, Seconds initretrydelay) <- getcfg $
Remote.gitconfig <$> transferRemote new
if numretries < maxretries