From 1a42b2c5a38e1dce0901d64f4db835054130fad1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Sep 2020 12:47:53 -0400 Subject: [PATCH] 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. --- Annex/Transfer.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Annex/Transfer.hs b/Annex/Transfer.hs index 90337c586e..973690a870 100644 --- a/Annex/Transfer.hs +++ b/Annex/Transfer.hs @@ -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