convert lockContent to use new LockPools

Also cleaned up the code, avoiding creating a lock file if we're going to
open it for create later anyway.

And, if there's an exception while preparing to lock the file, but not at
the point of actually taking the lock, throw an exception, instead of
silently not locking and pretending to succeed.

And, on Windows, always use lock file, even if the repo somehow got into
indirect mode (maybe with cygwin git..)
This commit is contained in:
Joey Hess 2015-05-19 14:10:13 -04:00
parent ecb0d5c087
commit 1312e721ed
2 changed files with 24 additions and 34 deletions

View file

@ -10,8 +10,6 @@ module Utility.LockFile.Posix (
lockShared,
lockExclusive,
tryLockExclusive,
createLockFile,
openExistingLockFile,
checkLocked,
getLockStatus,
dropLock,
@ -56,15 +54,6 @@ lock lockreq mode lockfile = do
waitToSetLock l (lockreq, AbsoluteSeek, 0, 0)
return (LockHandle l)
-- Create and opens lock file; does not lock it.
createLockFile :: FileMode -> LockFile -> IO Fd
createLockFile filemode = openLockFile (Just filemode)
-- Opens an existing lock file; does not lock it, and if it does not exist,
-- returns Nothing.
openExistingLockFile :: LockFile -> IO (Maybe Fd)
openExistingLockFile = catchMaybeIO . openLockFile Nothing
-- Close on exec flag is set so child processes do not inherit the lock.
openLockFile :: Maybe FileMode -> LockFile -> IO Fd
openLockFile filemode lockfile = do