summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-28 13:37:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-28 13:37:03 -0400
commit4888c5b0422c8006b4c178503b24bced733931fa (patch)
treee171586eddc9a0bcd0c8f2af3097121f2c25d3a6 /Assistant
parent40f357fdcf07a9b9844e675fe478ab08f5c1bae8 (diff)
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.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/Merger.hs2
-rw-r--r--Assistant/Threads/Watcher.hs2
2 files changed, 2 insertions, 2 deletions
diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs
index de172e8da..5d24d1862 100644
--- a/Assistant/Threads/Merger.hs
+++ b/Assistant/Threads/Merger.hs
@@ -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 ()
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 1b6ec15f1..e250f4b4a 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -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