aboutsummaryrefslogtreecommitdiff
path: root/RemoteDaemon
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-08 13:51:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-08 13:51:49 -0400
commitf2426676defafecc904234de3522f57ebf7ab19d (patch)
tree4b7b071b9f6029fb84d619a0df98454e3a7d1a32 /RemoteDaemon
parent6e47a1412175cbc00f44ea8dc663ad83331cfb6d (diff)
fix STOP
Diffstat (limited to 'RemoteDaemon')
-rw-r--r--RemoteDaemon/Core.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/RemoteDaemon/Core.hs b/RemoteDaemon/Core.hs
index cd4a0aaed..a220e5807 100644
--- a/RemoteDaemon/Core.hs
+++ b/RemoteDaemon/Core.hs
@@ -29,8 +29,6 @@ runForeground = do
ichan <- newChan :: IO (Chan Consumed)
ochan <- newChan :: IO (Chan Emitted)
- void $ async $ controller ichan ochan
-
let reader = forever $ do
l <- getLine
case parseMessage l of
@@ -40,18 +38,18 @@ runForeground = do
msg <- readChan ochan
putStrLn $ unwords $ formatMessage msg
hFlush stdout
+ let controller = runController ichan ochan
- -- If the reader or writer fails, for example because stdin/stdout
- -- gets closed, kill the other one, and throw an exception which
- -- will take down the daemon.
- void $ concurrently reader writer
+ -- If any thread fails, the rest will be killed.
+ void $ tryIO $
+ reader `concurrently` writer `concurrently` controller
type RemoteMap = M.Map Git.Repo (IO (), Chan Consumed)
-- Runs the transports, dispatching messages to them, and handling
-- the main control messages.
-controller :: Chan Consumed -> Chan Emitted -> IO ()
-controller ichan ochan = do
+runController :: Chan Consumed -> Chan Emitted -> IO ()
+runController ichan ochan = do
h <- genTransportHandle
m <- genRemoteMap h ochan
startrunning m