From 35c7ea8b01a849aceca5c017989043d4cb6fe8a6 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 27 May 2017 10:26:44 -0400 Subject: [iserv] move forkIO This moves the forkIO into the `startSlave` function from the `startSlave'` function, such that this allows consumers to call `forkSlave'` if they want the blocking behaviour. Reviewers: bgamari, austin Reviewed By: bgamari Subscribers: Ericson2314, ryantrinkle, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3601 --- iserv/src/Remote/Slave.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'iserv') diff --git a/iserv/src/Remote/Slave.hs b/iserv/src/Remote/Slave.hs index 11cc68a13a..c5b652da94 100644 --- a/iserv/src/Remote/Slave.hs +++ b/iserv/src/Remote/Slave.hs @@ -46,14 +46,18 @@ startSlave verbose port s = do putStr "DocRoot: " base_path <- peekCString s putStrLn base_path - startSlave' verbose base_path (toEnum port) + _ <- forkIO $ startSlave' verbose base_path (toEnum port) + return () +-- | @startSlave'@ provdes a blocking haskell interface, that +-- the hosting application on the target can use to start the +-- slave process. startSlave' :: Bool -> String -> PortNumber -> IO () startSlave' verbose base_path port = do sock <- openSocket port - _ <- forkIO $ forever $ do + forever $ do when verbose $ putStrLn "Opening socket" pipe <- acceptSocket sock >>= socketToPipe putStrLn $ "Listening on port " ++ show port @@ -62,8 +66,6 @@ startSlave' verbose base_path port = do when verbose $ putStrLn "serv ended" return () - return () - -- | The iserv library may need access to files, specifically -- archives and object files to be linked. If ghc and the slave -- are on the same host, this is trivial, as the underlying -- cgit v1.2.1