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.
This commit is contained in:
Joey Hess 2012-06-28 13:37:03 -04:00
parent 40f357fdcf
commit 4888c5b042
4 changed files with 33 additions and 11 deletions

View file

@ -35,7 +35,7 @@ mergeThread st = do
{ addHook = hook onAdd
, errHook = hook onErr
}
watchDir dir (const False) hooks id
void $ watchDir dir (const False) hooks id
type Handler = Git.Repo -> FilePath -> Maybe FileStatus -> IO ()

View file

@ -46,7 +46,7 @@ needLsof = error $ unlines
]
watchThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO ()
watchThread st dstatus changechan = watchDir "." ignored hooks startup
watchThread st dstatus changechan = void $ watchDir "." ignored hooks startup
where
startup = statupScan st dstatus
hook a = Just $ runHandler st dstatus changechan a