diff --git a/Annex/Init.hs b/Annex/Init.hs index b9d41b0eaf..b05a7d6871 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -230,9 +230,10 @@ probeLockSupport = withEventuallyCleanedOtherTmp $ \tmp -> do where go f mode = do nukeFile f - let locktest = mask $ const $ - Posix.lockExclusive (Just mode) f - >>= Posix.dropLock + let locktest = bracket + (Posix.lockExclusive (Just mode) f) + Posix.dropLock + (const noop) ok <- isRight <$> tryNonAsync locktest nukeFile f return ok diff --git a/Annex/LockPool/PosixOrPid.hs b/Annex/LockPool/PosixOrPid.hs index e078424390..6230544117 100644 --- a/Annex/LockPool/PosixOrPid.hs +++ b/Annex/LockPool/PosixOrPid.hs @@ -94,5 +94,4 @@ tryPidLock m f posixlock = debugLocks $ liftIO . go =<< pidLockFile -- avoid complicating any code that might expect to be able to see that -- lock file. But, it's not locked. dummyPosixLock :: Maybe FileMode -> LockFile -> IO () -dummyPosixLock m f = mask $ const $ - closeFd =<< openLockFile ReadLock m f +dummyPosixLock m f = bracket (openLockFile ReadLock m f) closeFd (const noop) diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs index be3a9b7f3e..d44785897b 100644 --- a/Remote/Helper/Ssh.hs +++ b/Remote/Helper/Ssh.hs @@ -200,7 +200,7 @@ closeP2PSshConnection :: P2PSshConnection -> IO (P2PSshConnection, Maybe ExitCod closeP2PSshConnection P2P.ClosedConnection = return (P2P.ClosedConnection, Nothing) closeP2PSshConnection (P2P.OpenConnection (_st, conn, pid, stderrhandlerst)) = -- mask async exceptions, avoid cleanup being interrupted - mask $ const $ do + uninterruptibleMask_ $ do P2P.closeConnection conn atomically $ writeTVar stderrhandlerst EndStderrHandler exitcode <- waitForProcess pid diff --git a/Utility/LockFile/Posix.hs b/Utility/LockFile/Posix.hs index 03c9e96c14..011d8f953b 100644 --- a/Utility/LockFile/Posix.hs +++ b/Utility/LockFile/Posix.hs @@ -58,7 +58,7 @@ lock lockreq mode lockfile = do -- Tries to take an lock, but does not block. tryLock :: LockRequest -> Maybe FileMode -> LockFile -> IO (Maybe LockHandle) -tryLock lockreq mode lockfile = mask $ const $ do +tryLock lockreq mode lockfile = uninterruptibleMask_ $ do l <- openLockFile lockreq mode lockfile v <- tryIO $ setLock l (lockreq, AbsoluteSeek, 0, 0) case v of