summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-12 19:39:28 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-12 19:39:28 -0400
commit608d5c78eff618bf54861ee77c69a424eeb6d25c (patch)
tree08eb059f08e0d48e094113f69433af91f64ea4f0 /Annex
parent6105e33c7f72c7a81bb78f06581cbf0a67594e6d (diff)
Fix an unlikely race that could result in two transfers of the same key running at once.
As discussed in bug report.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Transfer.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Annex/Transfer.hs b/Annex/Transfer.hs
index 1d7f2b98f..14a888620 100644
--- a/Annex/Transfer.hs
+++ b/Annex/Transfer.hs
@@ -87,9 +87,12 @@ runTransfer' ignorelock t file shouldretry transferobserver transferaction = do
r <- tryLockExclusive (Just mode) lck
case r of
Nothing -> return (Nothing, True)
- Just lockhandle -> do
+ Just lockhandle -> ifM (checkSaneLock lck lockhandle)
+ ( do
void $ tryIO $ writeTransferInfoFile info tfile
return (Just lockhandle, False)
+ , return (Nothing, True)
+ )
#else
prep tfile _mode info = do
let lck = transferLockFile tfile