]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer...
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 4 Mar 2015 19:51:55 +0000 (20:51 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 4 Mar 2015 19:51:55 +0000 (20:51 +0100)
Misc/NEWS
Modules/_ssl.c

index a211e5d7af5819a38d4ea24214315c86c591cbc1..c480033fcaa65b7cea0db35388c77978078ccad3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,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 #23458: On POSIX, the file descriptor kept open by os.urandom() is now
index e0d888e389b820e4a27f85161442cb481ba46448..f9d66a1dd9c9cc5f98bf4fb19e7e3400bd366599 100644 (file)
@@ -1720,26 +1720,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
     BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
     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(PySSLErrorObject,
-                            "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);