diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2015-03-04 20:54:57 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2015-03-04 20:54:57 +0100 |
commit | 056c654b390b083df3faf1d80b28a8bbb5fc86f1 (patch) | |
tree | 8f404a74fa2d4143e913289ab8ea6a7e4ad70afc | |
parent | 3c1a62e64f25ffeb99fc7a6f46480c6299956e78 (diff) | |
parent | c39f7c24ffa8fdc5f920169d023587ea780b65ff (diff) | |
download | cpython-056c654b390b083df3faf1d80b28a8bbb5fc86f1.tar.gz |
Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed.
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_ssl.c | 20 |
2 files changed, 3 insertions, 20 deletions
@@ -13,6 +13,9 @@ Core and Builtins 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 --git a/Modules/_ssl.c b/Modules/_ssl.c index 0e6abda975..4f23097990 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1841,26 +1841,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args) 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); |