changeset: 94848:fc0201ccbcd4 parent: 94846:cad6eac598ec parent: 94847:01cf9ce75eda user: Antoine Pitrou date: Wed Mar 04 20:54:57 2015 +0100 files: Misc/NEWS Modules/_ssl.c description: Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed. diff -r cad6eac598ec -r fc0201ccbcd4 Misc/NEWS --- a/Misc/NEWS Wed Mar 04 18:40:10 2015 +0100 +++ b/Misc/NEWS Wed Mar 04 20:54:57 2015 +0100 @@ -13,6 +13,9 @@ Library ------- +- Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the + SSL layer but the underlying connection hasn't been closed. + - Issue #23504: Added an __all__ to the types module. - Issue #23563: Optimized utility functions in urllib.parse. diff -r cad6eac598ec -r fc0201ccbcd4 Modules/_ssl.c --- a/Modules/_ssl.c Wed Mar 04 18:40:10 2015 +0100 +++ b/Modules/_ssl.c Wed Mar 04 20:54:57 2015 +0100 @@ -1841,26 +1841,6 @@ BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking); } - /* first check if there are bytes ready to be read */ - PySSL_BEGIN_ALLOW_THREADS - count = SSL_pending(self->ssl); - PySSL_END_ALLOW_THREADS - - if (!count) { - sockstate = check_socket_and_wait_for_timeout(sock, 0); - if (sockstate == SOCKET_HAS_TIMED_OUT) { - PyErr_SetString(PySocketModule.timeout_error, - "The read operation timed out"); - goto error; - } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) { - PyErr_SetString(PySSLErrorObject, - "Underlying socket too large for select()."); - goto error; - } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { - count = 0; - goto done; - } - } do { PySSL_BEGIN_ALLOW_THREADS count = SSL_read(self->ssl, mem, len);