From 8631d8de8373ec8226d19019ae7cf3a1bf2e44e5 Mon Sep 17 00:00:00 2001 From: PHO Date: Wed, 17 Feb 2010 15:47:05 +0900 Subject: [PATCH] Code cleanup --- Main.hs | 2 +- Rakka/Storage/Impl.hs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Main.hs b/Main.hs index 8ea363b..78de22f 100644 --- a/Main.hs +++ b/Main.hs @@ -267,7 +267,7 @@ withSystemLock lockfile = bracket lock' unlock' . const unlock' = closeFd withPidFile :: FilePath -> IO a -> IO a -withPidFile lockfile = bracket mkPid' (const delPid') . const +withPidFile lockfile = bracket_ mkPid' delPid' where mkPid' :: IO () mkPid' = withFile lockfile WriteMode $ \ h -> diff --git a/Rakka/Storage/Impl.hs b/Rakka/Storage/Impl.hs index e1bad11..bedc9ea 100644 --- a/Rakka/Storage/Impl.hs +++ b/Rakka/Storage/Impl.hs @@ -12,6 +12,7 @@ module Rakka.Storage.Impl import Control.Concurrent import Control.Concurrent.STM +import Control.Exception import Control.Monad import Data.Maybe import Data.Set (Set) @@ -107,7 +108,7 @@ startIndexManager :: FilePath -> Repository -> (Page -> IO Document) -> IO (TCha startIndexManager lsdir repos mkDraft = do chan <- newTChanIO index <- openIndex indexDir revFile - _ <- forkIO (loop chan index) + _ <- forkIO (loop chan index `finally` closeDatabase index) return chan where indexDir = lsdir "index" -- 2.40.0