summaryrefslogtreecommitdiff
path: root/Annex/Ssh.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-20 16:45:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-20 16:45:58 -0400
commit679d9c0027ac996eea9f41a6f0f39af436801e89 (patch)
treed98ae7ba049e2daa4a99e6bcf55054bde5e5ab4d /Annex/Ssh.hs
parent86f9d7734d0c638d4c966fd87a5d7e97759e125b (diff)
reorganize and refactor lock code
Added a convenience Utility.LockFile that is not a windows/posix portability shim, but still manages to cut down on the boilerplate around locking. This commit was sponsored by Johan Herland.
Diffstat (limited to 'Annex/Ssh.hs')
-rw-r--r--Annex/Ssh.hs5
1 files changed, 2 insertions, 3 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 4b3ee85e5..2b1b809ff 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -35,6 +35,7 @@ import Config.Files
import Utility.Env
import Types.CleanupActions
import Annex.Index (addGitEnv)
+import Utility.LockFile
#ifndef mingw32_HOST_OS
import Annex.Perms
#endif
@@ -151,9 +152,7 @@ sshCleanup = mapM_ cleanup =<< enumSocketFiles
let lockfile = socket2lock socketfile
unlockFile lockfile
mode <- annexFileMode
- fd <- liftIO $ noUmask mode $
- openFd lockfile ReadWrite (Just mode) defaultFileFlags
- liftIO $ setFdOption fd CloseOnExec True
+ fd <- liftIO $ noUmask mode $ createLockFile (Just mode) lockfile
v <- liftIO $ tryIO $
setLock fd (WriteLock, AbsoluteSeek, 0, 0)
case v of