Skip to content

Commit f7f3b0a

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.
1 parent 7beb4f9 commit f7f3b0a

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

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 #20204: Added the __module__ attribute to _tkinter classes.

Modules/_ssl.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,26 +1717,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
17171717
BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
17181718
BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
17191719

1720-
/* first check if there are bytes ready to be read */
1721-
PySSL_BEGIN_ALLOW_THREADS
1722-
count = SSL_pending(self->ssl);
1723-
PySSL_END_ALLOW_THREADS
1724-
1725-
if (!count) {
1726-
sockstate = check_socket_and_wait_for_timeout(sock, 0);
1727-
if (sockstate == SOCKET_HAS_TIMED_OUT) {
1728-
PyErr_SetString(PySocketModule.timeout_error,
1729-
"The read operation timed out");
1730-
goto error;
1731-
} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
1732-
PyErr_SetString(PySSLErrorObject,
1733-
"Underlying socket too large for select().");
1734-
goto error;
1735-
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
1736-
count = 0;
1737-
goto done;
1738-
}
1739-
}
17401720
do {
17411721
PySSL_BEGIN_ALLOW_THREADS
17421722
count = SSL_read(self->ssl, mem, len);

0 commit comments

Comments
 (0)