]> granicus.if.org Git - python/commitdiff
The do_handshake() method of SSL objects now adjusts the blocking mode of
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 24 Apr 2010 19:57:01 +0000 (19:57 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 24 Apr 2010 19:57:01 +0000 (19:57 +0000)
the SSL structure if necessary (as other methods already do).

Misc/NEWS
Modules/_ssl.c

index e9b3caf333551fecfb17ba93c2a61f282d9fce36..b9bdc9716a9ba1d329279cd4e3baf0389e11aedd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@ Core and Builtins
 Library
 -------
 
+- The do_handshake() method of SSL objects now adjusts the blocking mode of
+  the SSL structure if necessary (as other methods already do).
+
 - Issue #7507: Quote "!" in pipes.quote(); it is special to some shells.
 
 - Issue #5238: Calling makefile() on an SSL object would prevent the
index d19bf2d488fcb64e82e266fce3eb9913c3a7b69a..e81c219dbbb727dfd525186ecdb175deb017a785 100644 (file)
@@ -455,7 +455,12 @@ static PyObject *PySSL_SSLdo_handshake(PySSLObject *self)
 {
        int ret;
        int err;
-       int sockstate;
+       int sockstate, nonblocking;
+
+       /* just in case the blocking state of the socket has been changed */
+       nonblocking = (self->Socket->sock_timeout >= 0.0);
+       BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
+       BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
 
        /* Actually negotiate SSL connection */
        /* XXX If SSL_do_handshake() returns 0, it's also a failure. */