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
|
@ -6,6 +6,7 @@ git-annex (8.20211124) UNRELEASED; urgency=medium
|
|||
erroring out.
|
||||
* export: Avoid unncessarily re-exporting non-annexed files that were
|
||||
already exported.
|
||||
* Fix locking bug introduced in version 8.20200814.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Tue, 23 Nov 2021 15:58:27 -0400
|
||||
|
||||
|
|
|
@ -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
Reference in a new issue