summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-20 19:09:54 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-20 19:30:40 -0400
commitb85c3e0455125a192000fd828348e2b410b2569c (patch)
tree5a26bdb0fb4e86afb42d11ff3d26e58ad69c52f4 /Logs
parent263c4140583aeddd2c1e52a40d5fcc411f3d18d1 (diff)
final scary locking refactoring (for now)
Note that while before checkTransfer this called getLock with WriteLock, getLockStatus's use of ReadLock will also notice any exclusive locks. Since transfer info files are only locked exclusively, never shared, there is no behavior change. Also, fixes checkLocked to actually return Just False when the file exists, but is not locked.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Transfer.hs17
1 files changed, 6 insertions, 11 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index 7928972b3..16c3ebb68 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -129,17 +129,12 @@ checkTransfer :: Transfer -> Annex (Maybe TransferInfo)
checkTransfer t = do
tfile <- fromRepo $ transferFile t
#ifndef mingw32_HOST_OS
- mfd <- liftIO $ openExistingLockFile (transferLockFile tfile)
- case mfd of
- Nothing -> return Nothing -- failed to open file; not running
- Just fd -> do
- locked <- liftIO $
- getLock fd (WriteLock, AbsoluteSeek, 0, 0)
- liftIO $ closeFd fd
- case locked of
- Nothing -> return Nothing
- Just (pid, _) -> liftIO $ catchDefaultIO Nothing $
- readTransferInfoFile (Just pid) tfile
+ liftIO $ do
+ v <- getLockStatus (transferLockFile tfile)
+ case v of
+ Just (pid, _) -> catchDefaultIO Nothing $
+ readTransferInfoFile (Just pid) tfile
+ Nothing -> return Nothing
#else
v <- liftIO $ lockShared $ transferLockFile tfile
liftIO $ case v of