[commit: ghc] master: [iserv] move forkIO (35c7ea8)

git at git.haskell.org git at git.haskell.org
Fri Jun 2 16:28:12 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/35c7ea8b01a849aceca5c017989043d4cb6fe8a6/ghc

>---------------------------------------------------------------

commit 35c7ea8b01a849aceca5c017989043d4cb6fe8a6
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Sat May 27 10:26:44 2017 -0400

    [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


>---------------------------------------------------------------

35c7ea8b01a849aceca5c017989043d4cb6fe8a6
 iserv/src/Remote/Slave.hs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/iserv/src/Remote/Slave.hs b/iserv/src/Remote/Slave.hs
index 11cc68a..c5b652d 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



More information about the ghc-commits mailing list