Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0bfd0a4

Browse files
committed
Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed.
2 parents 9672da7 + f7f3b0a commit 0bfd0a4

2 files changed

Lines changed: 3 additions & 20 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
- Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the
17+
SSL layer but the underlying connection hasn't been closed.
18+
1619
- Issue #23504: Added an __all__ to the types module.
1720

1821
- Issue #23563: Optimized utility functions in urllib.parse.

Modules/_ssl.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,26 +1841,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
18411841
BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
18421842
}
18431843

1844-
/* first check if there are bytes ready to be read */
1845-
PySSL_BEGIN_ALLOW_THREADS
1846-
count = SSL_pending(self->ssl);
1847-
PySSL_END_ALLOW_THREADS
1848-
1849-
if (!count) {
1850-
sockstate = check_socket_and_wait_for_timeout(sock, 0);
1851-
if (sockstate == SOCKET_HAS_TIMED_OUT) {
1852-
PyErr_SetString(PySocketModule.timeout_error,
1853-
"The read operation timed out");
1854-
goto error;
1855-
} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
1856-
PyErr_SetString(PySSLErrorObject,
1857-
"Underlying socket too large for select().");
1858-
goto error;
1859-
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
1860-
count = 0;
1861-
goto done;
1862-
}
1863-
}
18641844
do {
18651845
PySSL_BEGIN_ALLOW_THREADS
18661846
count = SSL_read(self->ssl, mem, len);

0 commit comments

Comments
 (0)