summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-28 14:17:14 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-28 14:42:03 -0400
commite48f551505b3923d7c17e3b42330060e84129673 (patch)
tree5de335f5cc25b39a5d4ca12fdb6a076e03cf34db /Remote
parent4a923c3ee0e238ccc17881179bec77c6531e3ad4 (diff)
use locking on Windows
This is all the easy cases, where there was already a separate lock file.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Helper/Hooks.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Remote/Helper/Hooks.hs b/Remote/Helper/Hooks.hs
index 91c6318bf..f876649f0 100644
--- a/Remote/Helper/Hooks.hs
+++ b/Remote/Helper/Hooks.hs
@@ -17,6 +17,8 @@ import qualified Annex
import Annex.LockPool
#ifndef mingw32_HOST_OS
import Annex.Perms
+#else
+import Utility.WinLock
#endif
{- Modifies a remote's access functions to first run the
@@ -73,13 +75,13 @@ runHooks r starthook stophook a = do
run starthook
Annex.addCleanup (remoteid ++ "-stop-command") $ runstop lck
-#ifndef mingw32_HOST_OS
runstop lck = do
-- Drop any shared lock we have, and take an
-- exclusive lock, without blocking. If the lock
-- succeeds, we're the only process using this remote,
-- so can stop it.
unlockFile lck
+#ifndef mingw32_HOST_OS
mode <- annexFileMode
fd <- liftIO $ noUmask mode $
openFd lck ReadWrite (Just mode) defaultFileFlags
@@ -90,5 +92,10 @@ runHooks r starthook stophook a = do
Right _ -> run stophook
liftIO $ closeFd fd
#else
- runstop _lck = run stophook
+ v <- liftIO $ lockExclusive lck
+ case v of
+ Nothing -> noop
+ Just lockhandle -> do
+ run stophook
+ liftIO $ dropLock lockhandle
#endif