@@ -20,6 +20,7 @@ import Control.Distributed.Process.Internal.CQueue
2020 )
2121import Control.Distributed.Process.Internal.Primitives
2222 ( catch
23+ , finally
2324 , die
2425 , receiveWait
2526 , forward
@@ -27,6 +28,7 @@ import Control.Distributed.Process.Internal.Primitives
2728 , match
2829 , matchAny
2930 , matchAnyIf
31+ , matchIf
3032 , handleMessage
3133 , matchUnknown
3234 , whereis
@@ -163,16 +165,16 @@ logfileTracer p = do
163165 liftIO $ putStrLn $ "writing to " ++ (show p)
164166 h <- liftIO $ openFile p AppendMode
165167 liftIO $ hSetBuffering h LineBuffering
166− logger h `catch` (\(_ :: SomeException) -> liftIO $ hClose h)
168+ logger h `finally` (liftIO $ hClose h)
167169 where
168170 logger :: Handle -> Process ()
169171 logger h' = forever' $ do
170172 receiveWait [
171− matchAnyIf (\ev -> case ev of
172− TraceEvDisable -> True
173− (TraceEvTakeover _) -> True
174− _ -> False)
175− (\_ -> (liftIO $ hClose h') >> die "trace stopped")
173+ matchIf (\ev -> case ev of
174+ TraceEvDisable -> True
175+ (TraceEvTakeover _) -> True
176+ _ -> False)
177+ (\_ -> (liftIO $ hClose h') >> die "trace stopped")
176178 , matchAny (\ev -> handleMessage ev (writeTrace h'))
177179 ]
178180