From: Joey Hess Date: Wed, 27 Oct 2021 18:55:30 +0000 (-0400) Subject: add a comment about checkSaneLock X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~2^2^2~57^2~79 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a3cdff3fd52de12d0dda9004ea1212001a03d45c;p=git-annex.git add a comment about checkSaneLock See commit 8c2dd7d8ee814614bf3c871903b5d4d2aba193f4 for original introduction of it, but needing to spelunk that far back to understand the code is not good. --- diff --git a/Annex/Transfer.hs b/Annex/Transfer.hs index 119c91b1af..315033d219 100644 --- a/Annex/Transfer.hs +++ b/Annex/Transfer.hs @@ -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