From: PHO Date: Wed, 17 Feb 2010 06:47:05 +0000 (+0900) Subject: Code cleanup X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=8631d8de8373ec8226d19019ae7cf3a1bf2e44e5;p=Rakka.git Code cleanup --- 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"