diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-05-16 14:49:12 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-05-16 14:49:12 -0400 |
commit | d7820aa98ad0fe973d0a1aae2861abdab60de7a5 (patch) | |
tree | 5699a9b4ea84ff89931247fe527e9c0f44e06215 /Database/Keys/Handle.hs | |
parent | 0346651ab6ef0c53aa7e0daffd821863858081fe (diff) |
assistant: Fix race in v6 mode that caused downloaded file content to sometimes not replace pointer files.
The keys database handle needs to be closed after merging, because the
smudge filter, in another process, updates the database. Old cached info
can be read for a while from the open database handle; closing it ensures
that the info written by the smudge filter is available.
This is pretty horribly ad-hoc, and it's especially nasty that the
transferrer closes the database every time.
Diffstat (limited to 'Database/Keys/Handle.hs')
-rw-r--r-- | Database/Keys/Handle.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Database/Keys/Handle.hs b/Database/Keys/Handle.hs index 51de58fa8..1ef16d031 100644 --- a/Database/Keys/Handle.hs +++ b/Database/Keys/Handle.hs @@ -11,6 +11,7 @@ module Database.Keys.Handle ( DbState(..), withDbState, flushDbQueue, + closeDbHandle, ) where import qualified Database.Queue as H @@ -38,8 +39,7 @@ newDbHandle = DbHandle <$> newMVar DbClosed withDbState :: (MonadIO m, MonadCatch m) => DbHandle - -> (DbState - -> m (v, DbState)) + -> (DbState -> m (v, DbState)) -> m v withDbState (DbHandle mvar) a = do st <- liftIO $ takeMVar mvar @@ -55,3 +55,11 @@ flushDbQueue (DbHandle mvar) = go =<< readMVar mvar where go (DbOpen qh) = H.flushDbQueue qh go _ = return () + +closeDbHandle :: DbHandle -> IO () +closeDbHandle h = withDbState h go + where + go (DbOpen qh) = do + H.closeDbQueue qh + return ((), DbClosed) + go st = return ((), st) |