aboutsummaryrefslogtreecommitdiff
path: root/Annex/Ssh.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-20 18:56:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-20 18:58:14 -0400
commit263c4140583aeddd2c1e52a40d5fcc411f3d18d1 (patch)
treece22004cbe16525a6c649f84f3a4d216fb688236 /Annex/Ssh.hs
parent00d6acb7268239162a9ebd9386f7ca1271c3cc7d (diff)
more lock file refactoring
Also fixes a test suite failures introduced in recent commits, where inAnnexSafe failed in indirect mode, since it tried to open the lock file ReadWrite. This is why the new checkLocked opens it ReadOnly. This commit was sponsored by Chad Horohoe.
Diffstat (limited to 'Annex/Ssh.hs')
-rw-r--r--Annex/Ssh.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 2b1b809ff..ad636b4aa 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -152,13 +152,12 @@ sshCleanup = mapM_ cleanup =<< enumSocketFiles
let lockfile = socket2lock socketfile
unlockFile lockfile
mode <- annexFileMode
- fd <- liftIO $ noUmask mode $ createLockFile (Just mode) lockfile
- v <- liftIO $ tryIO $
- setLock fd (WriteLock, AbsoluteSeek, 0, 0)
+ v <- liftIO $ noUmask mode $ tryLockExclusive (Just mode) lockfile
case v of
- Left _ -> noop
- Right _ -> forceStopSsh socketfile
- liftIO $ closeFd fd
+ Nothing -> noop
+ Just lck -> do
+ forceStopSsh socketfile
+ liftIO $ dropLock lck
#else
forceStopSsh socketfile
#endif