diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-06-06 14:21:43 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-06-06 14:22:03 -0400 |
commit | 6b986240d9397563a888e40edc3c11857b36a4c3 (patch) | |
tree | 3de97c86c6af36391e81b11c785ce032c27a41f1 /Utility | |
parent | e57492d980d410eec4956b3df8c495c03a356666 (diff) |
Fix bug that prevented transfer locks from working when run on SMB or other filesystem that does not support fcntl locks and hard links.
This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/LockFile/PidLock.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Utility/LockFile/PidLock.hs b/Utility/LockFile/PidLock.hs index 23560fa57..0db9d1f3f 100644 --- a/Utility/LockFile/PidLock.hs +++ b/Utility/LockFile/PidLock.hs @@ -122,18 +122,21 @@ tryLock lockfile = trySideLock lockfile $ \sidelock -> do setFileMode tmp (combineModes readModes) hPutStr h . show =<< mkPidLock hClose h - st <- getFileStatus tmp - let failedlock = do + let failedlock st = do dropLock $ LockHandle tmp st sidelock return Nothing - let tooklock = return $ Just $ LockHandle lockfile' st sidelock + let tooklock st = return $ Just $ LockHandle lockfile' st sidelock ifM (linkToLock sidelock tmp lockfile') ( do nukeFile tmp - tooklock + -- May not have made a hard link, so stat + -- the lockfile + lckst <- getFileStatus lockfile' + tooklock lckst , do v <- readPidLock lockfile' hn <- getHostName + tmpst <- getFileStatus tmp case v of Just pl | isJust sidelock && hn == lockingHost pl -> do -- Since we have the sidelock, @@ -142,8 +145,8 @@ tryLock lockfile = trySideLock lockfile $ \sidelock -> do -- we know that the pidlock is -- stale, and can take it over. rename tmp lockfile' - tooklock - _ -> failedlock + tooklock tmpst + _ -> failedlock tmpst ) -- Linux's open(2) man page recommends linking a pid lock into place, |