◐ Shell
clean mode source ↗

bpo-41710: Add private _PyDeadline_Get() function by vstinner · Pull Request #28674 · python/cpython

Expand Up @@ -949,8 +949,9 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
timeout = GET_SOCKET_TIMEOUT(sock); has_timeout = (timeout > 0); if (has_timeout) deadline = _PyTime_GetMonotonicClock() + timeout; if (has_timeout) { deadline = _PyDeadline_Init(timeout); }
/* Actually negotiate SSL connection */ /* XXX If SSL_do_handshake() returns 0, it's also a failure. */ Expand All @@ -965,7 +966,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self) goto error;
if (has_timeout) timeout = deadline - _PyTime_GetMonotonicClock(); timeout = _PyDeadline_Get(deadline);
if (err.ssl == SSL_ERROR_WANT_READ) { sockstate = PySSL_select(sock, 0, timeout); Expand Down Expand Up @@ -2326,8 +2327,9 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
timeout = GET_SOCKET_TIMEOUT(sock); has_timeout = (timeout > 0); if (has_timeout) deadline = _PyTime_GetMonotonicClock() + timeout; if (has_timeout) { deadline = _PyDeadline_Init(timeout); }
sockstate = PySSL_select(sock, 1, timeout); if (sockstate == SOCKET_HAS_TIMED_OUT) { Expand All @@ -2354,8 +2356,9 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b) if (PyErr_CheckSignals()) goto error;
if (has_timeout) timeout = deadline - _PyTime_GetMonotonicClock(); if (has_timeout) { timeout = _PyDeadline_Get(deadline); }
if (err.ssl == SSL_ERROR_WANT_READ) { sockstate = PySSL_select(sock, 0, timeout); Expand Down Expand Up @@ -2494,7 +2497,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len, timeout = GET_SOCKET_TIMEOUT(sock); has_timeout = (timeout > 0); if (has_timeout) deadline = _PyTime_GetMonotonicClock() + timeout; deadline = _PyDeadline_Init(timeout);
do { PySSL_BEGIN_ALLOW_THREADS Expand All @@ -2506,8 +2509,9 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len, if (PyErr_CheckSignals()) goto error;
if (has_timeout) timeout = deadline - _PyTime_GetMonotonicClock(); if (has_timeout) { timeout = _PyDeadline_Get(deadline); }
if (err.ssl == SSL_ERROR_WANT_READ) { sockstate = PySSL_select(sock, 0, timeout); Expand Down Expand Up @@ -2592,8 +2596,9 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
timeout = GET_SOCKET_TIMEOUT(sock); has_timeout = (timeout > 0); if (has_timeout) deadline = _PyTime_GetMonotonicClock() + timeout; if (has_timeout) { deadline = _PyDeadline_Init(timeout); }
while (1) { PySSL_BEGIN_ALLOW_THREADS Expand Down Expand Up @@ -2626,8 +2631,9 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self) continue; }
if (has_timeout) timeout = deadline - _PyTime_GetMonotonicClock(); if (has_timeout) { timeout = _PyDeadline_Get(deadline); }
/* Possibly retry shutdown until timeout or failure */ if (err.ssl == SSL_ERROR_WANT_READ) Expand Down