combine retry deciders in better way
authorJoey Hess <joeyh@joeyh.name>
Fri, 4 Sep 2020 16:47:53 +0000 (12:47 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 4 Sep 2020 16:48:30 +0000 (12:48 -0400)
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

index 90337c586e0d4687021ef3bf6c1d61e3d26144f2..973690a8705febe9c13924007fc1d787d92cf025 100644 (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