mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] GH-113214: Fix SSLProto exception handling in SSL-over-SSL scenarios (GH-113334) (#113340)
When wrapped, `_SSLProtocolTransport._force_close(exc)` is called just like in the unwrapped scenario `_SelectorTransport._force_close(exc)` or `_ProactorBasePipeTransport._force_close(exc)` would be called, except here the exception needs to be passed through the `SSLProtocol._abort()` method, which didn't accept an exception object.
This commit ensures that this path works, in the same way that the uvloop implementation of SSLProto passes on the exception (on which the current implementation of SSLProto is based).
(cherry picked from commit 1ff0238594
)
Co-authored-by: Martijn Pieters <mj@zopatista.com>
This commit is contained in:
parent
d65dfc8238
commit
9cbe4738bc
3 changed files with 21 additions and 8 deletions
|
@ -243,13 +243,12 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
|
|||
The protocol's connection_lost() method will (eventually) be
|
||||
called with None as its argument.
|
||||
"""
|
||||
self._closed = True
|
||||
if self._ssl_protocol is not None:
|
||||
self._ssl_protocol._abort()
|
||||
self._force_close(None)
|
||||
|
||||
def _force_close(self, exc):
|
||||
self._closed = True
|
||||
self._ssl_protocol._abort(exc)
|
||||
if self._ssl_protocol is not None:
|
||||
self._ssl_protocol._abort(exc)
|
||||
|
||||
def _test__append_write_backlog(self, data):
|
||||
# for test only
|
||||
|
@ -614,7 +613,7 @@ class SSLProtocol(protocols.BufferedProtocol):
|
|||
if self._app_transport is not None:
|
||||
self._app_transport._closed = True
|
||||
if self._state == SSLProtocolState.DO_HANDSHAKE:
|
||||
self._abort()
|
||||
self._abort(None)
|
||||
else:
|
||||
self._set_state(SSLProtocolState.FLUSHING)
|
||||
self._shutdown_timeout_handle = self._loop.call_later(
|
||||
|
@ -661,10 +660,10 @@ class SSLProtocol(protocols.BufferedProtocol):
|
|||
else:
|
||||
self._loop.call_soon(self._transport.close)
|
||||
|
||||
def _abort(self):
|
||||
def _abort(self, exc):
|
||||
self._set_state(SSLProtocolState.UNWRAPPED)
|
||||
if self._transport is not None:
|
||||
self._transport.abort()
|
||||
self._transport._force_close(exc)
|
||||
|
||||
# Outgoing flow
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue