Fix reversion introduced in 6.20171214 that caused concurrent transfers to incorrectly fail with "transfer already in progress".
Avoid creating transfer info file before transfer lock is created and locked. The wrong order for one thing caused transfer info to be overwritten when a transfer was already in progress. But worse, it caused checkTransfer to see the transfer info, and so lock the transfer lock in order to verify the transfer was not in progress. Which in a concurrent situation, prevented the transferrer from locking the transfer lock, so it failed with "transfer already in progress". Note that the transferinfo command does not lock the transfer lock before creating the transfer info. But, that's only run after recvkey is running, and recvkey does lock the transfer lock, so that seems more or less ok. (Other than being a super complicated legacy mess that the P2P code has mostly obsoleted now.) This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
parent
da1b1fb991
commit
10d3b7fc62
6 changed files with 27 additions and 14 deletions
|
@ -73,9 +73,9 @@ alwaysRunTransfer = runTransfer' True
|
|||
runTransfer' :: Observable v => Bool -> Transfer -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex v) -> Annex v
|
||||
runTransfer' ignorelock t afile shouldretry transferaction = checkSecureHashes t $ do
|
||||
info <- liftIO $ startTransferInfo afile
|
||||
(meter, tfile, metervar) <- mkProgressUpdater t info
|
||||
(meter, tfile, createtfile, metervar) <- mkProgressUpdater t info
|
||||
mode <- annexFileMode
|
||||
(lck, inprogress) <- prep tfile mode info
|
||||
(lck, inprogress) <- prep tfile createtfile mode
|
||||
if inprogress && not ignorelock
|
||||
then do
|
||||
showNote "transfer already in progress, or unable to take transfer lock"
|
||||
|
@ -89,30 +89,28 @@ runTransfer' ignorelock t afile shouldretry transferaction = checkSecureHashes t
|
|||
return v
|
||||
where
|
||||
#ifndef mingw32_HOST_OS
|
||||
prep tfile mode info = catchPermissionDenied (const prepfailed) $ do
|
||||
prep tfile createtfile mode = catchPermissionDenied (const prepfailed) $ do
|
||||
let lck = transferLockFile tfile
|
||||
createAnnexDirectory $ takeDirectory lck
|
||||
tryLockExclusive (Just mode) lck >>= \case
|
||||
Nothing -> return (Nothing, True)
|
||||
Just lockhandle -> ifM (checkSaneLock lck lockhandle)
|
||||
( do
|
||||
void $ tryIO $
|
||||
writeTransferInfoFile info tfile
|
||||
createtfile
|
||||
return (Just lockhandle, False)
|
||||
, do
|
||||
liftIO $ dropLock lockhandle
|
||||
return (Nothing, True)
|
||||
)
|
||||
#else
|
||||
prep tfile _mode info = catchPermissionDenied (const prepfailed) $ do
|
||||
prep tfile createtfile _mode = catchPermissionDenied (const prepfailed) $ do
|
||||
let lck = transferLockFile tfile
|
||||
createAnnexDirectory $ takeDirectory lck
|
||||
catchMaybeIO (liftIO $ lockExclusive lck) >>= \case
|
||||
Nothing -> return (Nothing, False)
|
||||
Just Nothing -> return (Nothing, True)
|
||||
Just (Just lockhandle) -> do
|
||||
void $ tryIO $
|
||||
writeTransferInfoFile info tfile
|
||||
createtfile
|
||||
return (Just lockhandle, False)
|
||||
#endif
|
||||
prepfailed = return (Nothing, False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue