Author jacques
Recipients jacques
Date 2009-01-29.22:44:24
SpamBayes Score 1.13721e-08
Marked as misclassified No
Message-id <1233269067.88.0.11384047057.issue5103@psf.upfronthosting.co.za>
In-reply-to
Content
In ssl.py of Python 2.6.1 we have this code in  SSLSocket.__init__():

            if do_handshake_on_connect:
                timeout = self.gettimeout()
                try:
                    self.settimeout(None)
                    self.do_handshake()
                finally:
                    self.settimeout(timeout)

The problem is, what happens if the remote end (server) is hanging when
do_handshake() is called?  The result is that the user-requested timeout
will be ignored, and the connection will hang until the TCP socket
timeout expires.

This is easily reproducable with this test code:


import urllib2
urllib2.urlopen("https://localhost:9000/", timeout=2.0)


and running netcat on port 9000, i.e.:

nc -l -p 9000 localhost

If you use "http" instead of "https", the timeout works as expected
(after 2 seconds in this case).
History
Date User Action Args
2009-01-29 22:44:27jacquessetrecipients: + jacques
2009-01-29 22:44:27jacquessetmessageid: <1233269067.88.0.11384047057.issue5103@psf.upfronthosting.co.za>
2009-01-29 22:44:25jacqueslinkissue5103 messages
2009-01-29 22:44:24jacquescreate