summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-13 19:26:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-13 19:26:39 -0400
commit5573911d25e51c3434f1666ee415a0c0781714fc (patch)
treea1fef80f88909e70136d0e9685321935ba32716f
parent60c31afc3804734e8c85b1d3f4a530b9cdaf8b5e (diff)
Disable ssh connection caching if the path to the control socket would be too long (and use relative path to minimise path to the control socket).
-rw-r--r--Annex/Ssh.hs21
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn8
3 files changed, 29 insertions, 2 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 8bd4fe33a..46885393c 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -42,7 +42,13 @@ sshInfo (host, port) = ifM caching
( do
dir <- fromRepo gitAnnexSshDir
let socketfile = dir </> hostport2socket host port
- return (Just socketfile, cacheParams socketfile)
+ if valid_unix_socket_path socketfile
+ then return (Just socketfile, cacheParams socketfile)
+ else do
+ socketfile' <- liftIO $ relPathCwdToFile socketfile
+ if valid_unix_socket_path socketfile'
+ then return (Just socketfile', cacheParams socketfile')
+ else return (Nothing, [])
, return (Nothing, [])
)
where
@@ -118,3 +124,16 @@ isLock f = lockExt `isSuffixOf` f
lockExt :: String
lockExt = ".lock"
+
+{- This is the size of the sun_path component of sockaddr_un, which
+ - is the limit to the total length of the filename of a unix socket.
+ -
+ - On Linux, this is 108. On OSX, 104. TODO: Probe
+ -}
+sizeof_sockaddr_un_sun_path :: Int
+sizeof_sockaddr_un_sun_path = 100
+
+{- Note that this looks at the true length of the path in bytes, as it will
+ - appear on disk. -}
+valid_unix_socket_path :: FilePath -> Bool
+valid_unix_socket_path f = length (decodeW8 f) < sizeof_sockaddr_un_sun_path
diff --git a/debian/changelog b/debian/changelog
index f35b0e05d..0c0b34e0e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ git-annex (3.20120826) UNRELEASED; urgency=low
* test: Set a lot of git environment variables so testing works in strange
environments that normally need git config to set names, etc.
Closes: #682351 Thanks, gregor herrmann
+ * Disable ssh connection caching if the path to the control socket would be
+ too long (and use relative path to minimise path to the control socket).
-- Joey Hess <joeyh@debian.org> Mon, 27 Aug 2012 13:27:39 -0400
diff --git a/doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn b/doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn
index 1bc498dba..a86bd597d 100644
--- a/doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn
+++ b/doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn
@@ -41,4 +41,10 @@ stdout snippet from git-annex webapp:
This data appears on both the sending and receiving git-annex stdout. At least for the initial sync. For later syncs it only appears on the sender, though the client system is using a lot of resources.
-
+> I've made git-annex detect if the control path would be too long,
+> and disable ssh connection caching. It also tries a relative path
+> to the file, which tends to make it shorter, and I think would
+> keep ssh connection caching working in your example.
+>
+> Please test and see if it works, and also if the "looping" problem
+> still happens. --[[Joey]]