]> dgit.raspbian.org Git - git-annex.git/commitdiff
add a comment about checkSaneLock
authorJoey Hess <joeyh@joeyh.name>
Wed, 27 Oct 2021 18:55:30 +0000 (14:55 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 27 Oct 2021 18:55:30 +0000 (14:55 -0400)
See commit 8c2dd7d8ee814614bf3c871903b5d4d2aba193f4 for original
introduction of it, but needing to spelunk that far back to understand
the code is not good.

Annex/Transfer.hs

index 119c91b1af1de223abcfaca1a968cda0004a115b..315033d21908e39f7afc970f42378a004c705bf7 100644 (file)
@@ -151,6 +151,11 @@ runTransfer' ignorelock t afile stalldetection retrydecider transferaction =
                createAnnexDirectory $ P.takeDirectory lck
                tryLockExclusive (Just mode) lck >>= \case
                        Nothing -> return (Nothing, True)
+                       -- Since the lock file is removed in cleanup,
+                       -- there's a race where different processes
+                       -- may have a deleted and a new version of the same
+                       -- lock file open. checkSaneLock guards against
+                       -- that.
                        Just lockhandle -> ifM (checkSaneLock lck lockhandle)
                                ( do
                                        createtfile