summaryrefslogtreecommitdiff
path: root/Assistant/Threads/SanityChecker.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-28 18:02:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-28 18:02:11 -0400
commit3cc18857936e5a09e033439971dc9c43e6ccbaa2 (patch)
treea817de04aa65271b3036370d447cf1b228a4bffb /Assistant/Threads/SanityChecker.hs
parenta17fde22fabdb706086ac945bc331e32527b58bd (diff)
move DaemonStatus manipulation out of the Annex monad to IO
I've convinced myself that nothing in DaemonStatus can deadlock, as it always keepts the TMVar full. That was the only reason it was in the Annex monad.
Diffstat (limited to 'Assistant/Threads/SanityChecker.hs')
-rw-r--r--Assistant/Threads/SanityChecker.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs
index 09aee0797..5e27246a0 100644
--- a/Assistant/Threads/SanityChecker.hs
+++ b/Assistant/Threads/SanityChecker.hs
@@ -26,32 +26,28 @@ thisThread = "SanityChecker"
{- This thread wakes up occasionally to make sure the tree is in good shape. -}
sanityCheckerThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> IO ()
sanityCheckerThread st status transferqueue changechan = forever $ do
- waitForNextCheck st status
+ waitForNextCheck status
debug thisThread ["starting sanity check"]
- runThreadState st $
- modifyDaemonStatus_ status $ \s -> s
- { sanityCheckRunning = True }
+ modifyDaemonStatus_ status $ \s -> s
+ { sanityCheckRunning = True }
now <- getPOSIXTime -- before check started
catchIO (check st status transferqueue changechan)
(runThreadState st . warning . show)
- runThreadState st $ do
- modifyDaemonStatus_ status $ \s -> s
- { sanityCheckRunning = False
- , lastSanityCheck = Just now
- }
+ modifyDaemonStatus_ status $ \s -> s
+ { sanityCheckRunning = False
+ , lastSanityCheck = Just now
+ }
debug thisThread ["sanity check complete"]
-
{- Only run one check per day, from the time of the last check. -}
-waitForNextCheck :: ThreadState -> DaemonStatusHandle -> IO ()
-waitForNextCheck st status = do
- v <- runThreadState st $
- lastSanityCheck <$> getDaemonStatus status
+waitForNextCheck :: DaemonStatusHandle -> IO ()
+waitForNextCheck status = do
+ v <- lastSanityCheck <$> getDaemonStatus status
now <- getPOSIXTime
threadDelaySeconds $ Seconds $ calcdelay now v
where