components/python/paramiko/patches/02-socket-timeout.patch
branchs11-update
changeset 4508 d8924d870370
equal deleted inserted replaced
4506:e5c1a87858fd 4508:d8924d870370
       
     1 #
       
     2 # This patch addresses an issue when creating a paramiko client
       
     3 # connection and a timeout is specified. When a Transport object is being
       
     4 # instantiated, it overrides this timeout value all the time and it
       
     5 # should not.
       
     6 #
       
     7 # This patch is suitable for the upstream and a bug has been filed:
       
     8 #
       
     9 #	https://github.com/paramiko/paramiko/issues/476
       
    10 #
       
    11 
       
    12 --- paramiko-1.15.2/paramiko/transport.py.~2~	2015-04-12 18:39:08.295798093 -0700
       
    13 +++ paramiko-1.15.2/paramiko/transport.py	2015-04-12 18:39:49.250225381 -0700
       
    14 @@ -270,10 +270,13 @@ class Transport (threading.Thread, Closi
       
    15          self.sock = sock
       
    16          # Python < 2.3 doesn't have the settimeout method - RogerB
       
    17          try:
       
    18 -            # we set the timeout so we can check self.active periodically to
       
    19 -            # see if we should bail.  socket.timeout exception is never
       
    20 -            # propagated.
       
    21 -            self.sock.settimeout(0.1)
       
    22 +            # Only settimeout if not already set:
       
    23 +            timeout = self.sock.gettimeout()
       
    24 +            if timeout is None or timeout <= 0:
       
    25 +                # we set the timeout so we can check self.active periodically
       
    26 +                # to see if we should bail.  socket.timeout exception is never
       
    27 +                # propagated.
       
    28 +                self.sock.settimeout(0.1)
       
    29          except AttributeError:
       
    30              pass
       
    31  
       
    32 --- paramiko-1.15.2/tests/loop.py.~1~	2014-09-06 16:07:24.000000000 -0700
       
    33 +++ paramiko-1.15.2/tests/loop.py	2015-04-12 17:36:15.218573915 -0700
       
    34 @@ -73,6 +73,9 @@ class LoopSocket (object):
       
    35      def settimeout(self, n):
       
    36          self.__timeout = n
       
    37  
       
    38 +    def gettimeout(self):
       
    39 +        return self.__timeout
       
    40 +
       
    41      def link(self, other):
       
    42          self.__mate = other
       
    43          self.__mate.__mate = self