fix too early close of shared lock file
This fixes a reversion introduced in commit
ac56a5c2a0
.
I didn't notice there that it was handling the case of a shared lock
file that was still open elsewhere by not running the close action.
This was especially deadly when annex.pidlock is set, as it caused early
deletion of the pid lock file.
Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
f50de2455f
commit
66b2536ea0
2 changed files with 6 additions and 5 deletions
|
@ -122,15 +122,15 @@ releaseLock :: LockHandle -> IO ()
|
|||
releaseLock h = go =<< atomically (tryTakeTMVar h)
|
||||
where
|
||||
go (Just (pool, file, closelockfile)) = do
|
||||
m <- atomically $ do
|
||||
(m, lastuser) <- atomically $ do
|
||||
m <- takeTMVar pool
|
||||
return $ case M.lookup file m of
|
||||
Just (LockStatus mode n)
|
||||
| n == 1 -> (M.delete file m)
|
||||
| n == 1 -> (M.delete file m, True)
|
||||
| otherwise ->
|
||||
(M.insert file (LockStatus mode (pred n)) m)
|
||||
Nothing -> m
|
||||
() <- closelockfile
|
||||
(M.insert file (LockStatus mode (pred n)) m, False)
|
||||
Nothing -> (m, True)
|
||||
() <- when lastuser closelockfile
|
||||
atomically $ putTMVar pool m
|
||||
-- The LockHandle was already closed.
|
||||
go Nothing = return ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue