summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-11 18:08:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-11 18:08:46 -0400
commitd6df4fc3da982c7699f4d8acb3a0959ad4e5eb97 (patch)
tree5bca1505a944b7ae572c93eaa4d0d070010ce2a6
parent8da8ec730dc0df29dd97be861938deeb2488dda0 (diff)
guard against any remaining infinite recursion bugs; throw error if no candidate cn be found in next hundred years
Note that the exception thrown is not visible in the webapp currently because it crashes one of Cronner's 2 worker threads, which is never checked.
-rw-r--r--Utility/Scheduled.hs10
-rw-r--r--debian/changelog4
2 files changed, 10 insertions, 4 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index 45914aada..1b25cb4c7 100644
--- a/Utility/Scheduled.hs
+++ b/Utility/Scheduled.hs
@@ -86,7 +86,7 @@ nextTime schedule lasttime = do
{- Calculate the next time that fits a Schedule, based on the
- last time it occurred, and the current time. -}
calcNextTime :: Schedule -> Maybe LocalTime -> LocalTime -> Maybe NextTime
-calcNextTime (Schedule recurrance scheduledtime) lasttime currenttime
+calcNextTime schedule@(Schedule recurrance scheduledtime) lasttime currenttime
| scheduledtime == AnyTime = do
next <- findfromtoday True
return $ case next of
@@ -108,7 +108,13 @@ calcNextTime (Schedule recurrance scheduledtime) lasttime currenttime
window startd endd = NextTimeWindow
(LocalTime startd nexttime)
(LocalTime endd (TimeOfDay 23 59 0))
- findfrom r afterday candidate = case r of
+ findfrom r afterday candidate
+ | ynum candidate > (ynum (localDay currenttime)) + 100 =
+ -- avoid possible infinite recusion
+ error $ "bug: calcNextTime did not find a time within 100 years to run " ++
+ show (schedule, lasttime, currenttime)
+ | otherwise = findfromChecked r afterday candidate
+ findfromChecked r afterday candidate = case r of
Daily
| afterday -> Just $ exactly $ addDays 1 candidate
| otherwise -> Just $ exactly candidate
diff --git a/debian/changelog b/debian/changelog
index c3952f28f..a883ddda9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,8 @@
-git-annex (5.20140412) UNRELEASED; urgency=high
+git-annex (5.20140412) unstable; urgency=high
* Last release didn't quite fix the high cpu issue in all cases, this should.
- -- Joey Hess <joeyh@debian.org> Fri, 11 Apr 2014 17:13:07 -0400
+ -- Joey Hess <joeyh@debian.org> Fri, 11 Apr 2014 17:14:38 -0400
git-annex (5.20140411) unstable; urgency=high