summaryrefslogtreecommitdiff
path: root/Utility/LockPool/Posix.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-19 23:35:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-19 23:35:24 -0400
commit3237ddb564f5d2c07d03184d4f43c9c33c612a6c (patch)
tree7fef6e09b3cbcb6ea48d04b56cac070dd46df3c6 /Utility/LockPool/Posix.hs
parent8907359a875c2deb76d9386e398d97e4e4103fe2 (diff)
fix crash in stale transfer lockfile cleanup code
Need to differentiate between the lockfile not being locked, and it not existing.
Diffstat (limited to 'Utility/LockPool/Posix.hs')
-rw-r--r--Utility/LockPool/Posix.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Utility/LockPool/Posix.hs b/Utility/LockPool/Posix.hs
index e05ab9754..506d7b560 100644
--- a/Utility/LockPool/Posix.hs
+++ b/Utility/LockPool/Posix.hs
@@ -12,11 +12,13 @@ module Utility.LockPool.Posix (
tryLockExclusive,
checkLocked,
getLockStatus,
+ LockStatus(..),
dropLock,
checkSaneLock,
) where
import qualified Utility.LockFile.Posix as F
+import Utility.LockFile.Posix (LockStatus(..))
import qualified Utility.LockPool.STM as P
import Utility.LockPool.STM (LockFile, LockMode(..))
import Utility.LockPool.LockHandle
@@ -46,11 +48,13 @@ tryLockExclusive mode file = tryMakeLockHandle
-- Returns Nothing when the file doesn't exist, for cases where
-- that is different from it not being locked.
checkLocked :: LockFile -> IO (Maybe Bool)
-checkLocked file = P.getLockStatus P.lockPool file (pure True)
+checkLocked file = P.getLockStatus P.lockPool file
+ (pure (Just True))
(F.checkLocked file)
-getLockStatus :: LockFile -> IO (Maybe ProcessID)
-getLockStatus file = P.getLockStatus P.lockPool file getProcessID
+getLockStatus :: LockFile -> IO LockStatus
+getLockStatus file = P.getLockStatus P.lockPool file
+ (StatusLockedBy <$> getProcessID)
(F.getLockStatus file)
checkSaneLock :: LockFile -> LockHandle -> IO Bool