aboutsummaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-10-26 13:16:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-10-26 13:16:41 -0400
commit1a9da6bbe06818822e90018c9c5c3ba3146c25f9 (patch)
tree303a39a4d65204a2e0aa3813c6d4c63e6bb71ee2 /Annex
parent3b4b4e5043e6d2575971577be50893d3f9a9549b (diff)
Improve ssh socket cleanup code to skip over the cruft that NFS sometimes puts in a directory when a file is being deleted.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Ssh.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 10efa9f9e..4f879436b 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -136,11 +136,20 @@ prepSocket socketfile = do
liftIO $ createDirectoryIfMissing True $ parentDir socketfile
lockFileCached $ socket2lock socketfile
+{- Find ssh socket files.
+ -
+ - The check that the lock file exists makes only socket files
+ - that were set up by prepSocket be found. On some NFS systems,
+ - a deleted socket file may linger for a while under another filename;
+ - and this check makes such files be skipped since the corresponding lock
+ - file won't exist.
+ -}
enumSocketFiles :: Annex [FilePath]
-enumSocketFiles = go =<< sshCacheDir
+enumSocketFiles = liftIO . go =<< sshCacheDir
where
go Nothing = return []
- go (Just dir) = liftIO $ filter (not . isLock)
+ go (Just dir) = filterM (doesFileExist . socket2lock)
+ =<< filter (not . isLock)
<$> catchDefaultIO [] (dirContents dir)
{- Stop any unused ssh connection caching processes. -}