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.
|
erroring out.
|
||||||
* export: Avoid unncessarily re-exporting non-annexed files that were
|
* export: Avoid unncessarily re-exporting non-annexed files that were
|
||||||
already exported.
|
already exported.
|
||||||
|
* Fix locking bug introduced in version 8.20200814.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 23 Nov 2021 15:58:27 -0400
|
-- 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)
|
releaseLock h = go =<< atomically (tryTakeTMVar h)
|
||||||
where
|
where
|
||||||
go (Just (pool, file, closelockfile)) = do
|
go (Just (pool, file, closelockfile)) = do
|
||||||
m <- atomically $ do
|
(m, lastuser) <- atomically $ do
|
||||||
m <- takeTMVar pool
|
m <- takeTMVar pool
|
||||||
return $ case M.lookup file m of
|
return $ case M.lookup file m of
|
||||||
Just (LockStatus mode n)
|
Just (LockStatus mode n)
|
||||||
| n == 1 -> (M.delete file m)
|
| n == 1 -> (M.delete file m, True)
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
(M.insert file (LockStatus mode (pred n)) m)
|
(M.insert file (LockStatus mode (pred n)) m, False)
|
||||||
Nothing -> m
|
Nothing -> (m, True)
|
||||||
() <- closelockfile
|
() <- when lastuser closelockfile
|
||||||
atomically $ putTMVar pool m
|
atomically $ putTMVar pool m
|
||||||
-- The LockHandle was already closed.
|
-- The LockHandle was already closed.
|
||||||
go Nothing = return ()
|
go Nothing = return ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue