From 4eb6b55e980fda9c4d260820f5a6d38dde3d0991 Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 8 Sep 2014 15:43:20 +0000 Subject: (1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfo (1) introduces the module GF.Infra.Concurreny with lifted concurrency operators (to reduce uses of liftIO) and some additional concurrency utilities, e.g. a function for sequential logging that is used in both GF.CompileInParallel and GFServer. (2) avoids leaving broken .gfo files behind if compilation is aborted. --- src/compiler/GFServer.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/compiler/GFServer.hs') diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index a74167b9a..fbcca3d94 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -23,7 +23,7 @@ import System.FilePath(dropExtension,takeExtension,takeFileName,takeDirectory, import System.Posix.Files(getSymbolicLinkStatus,isSymbolicLink,removeLink, createSymbolicLink) #endif -import Control.Concurrent(forkIO,newMVar,modifyMVar,newChan,writeChan,getChanContents) +import GF.Infra.Concurrency(newMVar,modifyMVar,newLog) import Network.URI(URI(..)) import Network.Shed.Httpd(initServer,Request(..),Response(..),noCache) --import qualified Network.FastCGI as FCGI -- from hackage direct-fastcgi @@ -65,9 +65,7 @@ server port optroot execute1 state0 = where -- | HTTP server http_server execute1 state0 state cache root = - do log <- newChan -- to avoid intertwined log messages - forkIO $ mapM_ ePutStrLn =<< getChanContents log - let logLn = writeChan log + do logLn <- newLog ePutStrLn -- to avoid intertwined log messages logLn gf_version logLn $ "Document root = "++root logLn $ "Starting HTTP server, open http://localhost:" -- cgit v1.2.3