Enable usage of persistent connections with popen_scp (limited though)
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Mon, 3 Oct 2011 05:58:21 +0000 (07:58 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Mon, 3 Oct 2011 05:58:21 +0000 (07:58 +0200)
src/nepi/util/server.py

index 4430d6e..6f69577 100644 (file)
@@ -864,7 +864,12 @@ def popen_scp(source, dest,
         tmp_known_hosts = None
         args = ['scp', '-q', '-p', '-C',
                 # Don't bother with localhost. Makes test easier
-                '-o', 'NoHostAuthenticationForLocalhost=yes' ]
+                '-o', 'NoHostAuthenticationForLocalhost=yes',
+                '-o', 'ConnectTimeout=30',
+                '-o', 'ConnectionAttempts=3',
+                '-o', 'ServerAliveInterval=30',
+                '-o', 'TCPKeepAlive=yes' ]
+                
         if port:
             args.append('-P%d' % port)
         if recursive:
@@ -878,6 +883,11 @@ def popen_scp(source, dest,
         if isinstance(source,list):
             args.extend(source)
         else:
+            if openssh_has_persist():
+                connkey = make_connkey(user,host,port)
+                args.extend([
+                    '-o', 'ControlMaster=no',
+                    '-o', 'ControlPath=/tmp/nepi_ssh_pl_%s' % ( connkey, ) ])
             args.append(source)
         args.append(dest)