diff --git a/Misc/NEWS b/Misc/NEWS index 9aa8766ee25..1db6757b98e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,7 +28,9 @@ Library didn't support chflags() (for example ZFS under FreeBSD). The error is now silenced. -- Issue #3890: Fix recv() and recv_into() on non-blocking SSL sockets. +- Issue #3890, #8222: Fix recv() and recv_into() on non-blocking SSL sockets. + Also, enable the SSL_MODE_AUTO_RETRY flag on SSL sockets, so that blocking + reads and writes are always retried by OpenSSL itself. - Issue #6716/2: Backslash-replace error output in compilall. diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 45c44f888fd..913115824d9 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -9,8 +9,6 @@ directly. XXX should partial writes be enabled, SSL_MODE_ENABLE_PARTIAL_WRITE? - - XXX what about SSL_MODE_AUTO_RETRY? */ #include "Python.h" @@ -371,6 +369,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file, self->ssl = SSL_new(self->ctx); /* New ssl struct */ PySSL_END_ALLOW_THREADS SSL_set_fd(self->ssl, Sock->sock_fd); /* Set the socket for SSL */ + SSL_set_mode(self->ssl, SSL_MODE_AUTO_RETRY); /* If the socket is in non-blocking mode or timeout mode, set the BIO * to non-blocking mode (blocking is the default)