components/python/paramiko/patches/02-socket-timeout.patch
author Matt Keenan <matt.keenan@oracle.com>
Wed, 10 Jun 2015 10:12:11 +0100
changeset 4460 e5811789e2fb
permissions -rw-r--r--
PSARC 2015/172 OpenStack Ironic (OpenStack Bare Metal Provisioning Service) PSARC 2015/070 pecan - Lightweight Python web-framework PSARC 2015/071 PyCA Python Cryptography PSARC 2015/170 OpenStack client for Ironic (Bare Metal Provisioning) PSARC 2015/171 scp - python secure copy PSARC 2015/196 singledispatch - Single-dispatch generic functions for Python PSARC 2015/197 logutils - Set of handlers for standard Python logging library PSARC 2015/198 Support for enumerations in Python 2.6 and 2.7 PSARC 2015/250 paramiko - SSHv2 protocol implementation in Python 20547142 Request to integrate Ironic into userland 17502639 The Python paramiko module should be added to Userland 20172780 The Python module scp should be added to Userland 20180376 The Python module ironicclient should be added to Userland 20182588 The Python module pecan should be added to Userland 20465525 The PyCA cryptography module should be added to Userland 20904396 The Python module singledispatch should be added to Userland 20904413 The Python module logutils should be added to Userland 20917993 The Python enum34 module should be added to Userland

#
# This patch addresses an issue when creating a paramiko client
# connection and a timeout is specified. When a Transport object is being
# instantiated, it overrides this timeout value all the time and it
# should not.
#
# This patch is suitable for the upstream and a bug has been filed:
#
#	https://github.com/paramiko/paramiko/issues/476
#

--- paramiko-1.15.2/paramiko/transport.py.~2~	2015-04-12 18:39:08.295798093 -0700
+++ paramiko-1.15.2/paramiko/transport.py	2015-04-12 18:39:49.250225381 -0700
@@ -270,10 +270,13 @@ class Transport (threading.Thread, Closi
         self.sock = sock
         # Python < 2.3 doesn't have the settimeout method - RogerB
         try:
-            # we set the timeout so we can check self.active periodically to
-            # see if we should bail.  socket.timeout exception is never
-            # propagated.
-            self.sock.settimeout(0.1)
+            # Only settimeout if not already set:
+            timeout = self.sock.gettimeout()
+            if timeout is None or timeout <= 0:
+                # we set the timeout so we can check self.active periodically
+                # to see if we should bail.  socket.timeout exception is never
+                # propagated.
+                self.sock.settimeout(0.1)
         except AttributeError:
             pass
 
--- paramiko-1.15.2/tests/loop.py.~1~	2014-09-06 16:07:24.000000000 -0700
+++ paramiko-1.15.2/tests/loop.py	2015-04-12 17:36:15.218573915 -0700
@@ -73,6 +73,9 @@ class LoopSocket (object):
     def settimeout(self, n):
         self.__timeout = n
 
+    def gettimeout(self):
+        return self.__timeout
+
     def link(self, other):
         self.__mate = other
         self.__mate.__mate = self