From a3cdff3fd52de12d0dda9004ea1212001a03d45c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 Oct 2021 14:55:30 -0400 Subject: [PATCH] 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. --- Annex/Transfer.hs | 5 +++++ 1 file changed, 5 insertions(+) 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 -- 2.39.5