diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2017-05-27 10:26:44 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-06-02 12:27:45 -0400 |
commit | 35c7ea8b01a849aceca5c017989043d4cb6fe8a6 (patch) | |
tree | 16d4094e6118e88e0145bec5d74cf88057ff7116 /iserv/src/Remote/Slave.hs | |
parent | 750a25f47b626e6495cc6f951eca071429744767 (diff) | |
download | haskell-35c7ea8b01a849aceca5c017989043d4cb6fe8a6.tar.gz |
[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
Diffstat (limited to 'iserv/src/Remote/Slave.hs')
-rw-r--r-- | iserv/src/Remote/Slave.hs | 10 |
1 files changed, 6 insertions, 4 deletions
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 |