From 4888c5b0422c8006b4c178503b24bced733931fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 28 Jun 2012 13:37:03 -0400 Subject: improve thread termination handling The reason the DirWatcher had to wait for program termination was because it used withINotify, so when it finished, its watcher threads were killed. But since I have two DirWatcher threads now, that was not good, and could perhaps explain the MVar problem I saw yesterday. In any case, fixed this part of the code by making the DirWatcher return a handle that can be used to stop it, and now the main Assistant thread is the only one calling waitForTermination. --- Assistant.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Assistant.hs') diff --git a/Assistant.hs b/Assistant.hs index b61270613..2a11741b4 100644 --- a/Assistant.hs +++ b/Assistant.hs @@ -73,6 +73,7 @@ import Assistant.Threads.Merger import Assistant.Threads.SanityChecker import qualified Utility.Daemon import Utility.LogFile +import Utility.ThreadScheduler import Control.Concurrent @@ -99,8 +100,8 @@ startDaemon assistant foreground _ <- forkIO $ mergeThread st _ <- forkIO $ daemonStatusThread st dstatus _ <- forkIO $ sanityCheckerThread st dstatus changechan - -- Does not return. - watchThread st dstatus changechan + _ <- forkIO $ watchThread st dstatus changechan + waitForTermination stopDaemon :: Annex () stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile -- cgit v1.2.3