From dcc7fbc989ab6e0b59db441f7f804e6cc02f6750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Sgha=C3=AFer?= Date: Fri, 9 Jun 2017 18:29:46 -0400 Subject: [PATCH] Break circular references when closing SSLTransport objects (#981) --- Lib/asyncio/sslproto.py | 10 ++++++---- Misc/NEWS | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 6e9ce2968a0826..7948c4c3b4efe6 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -686,12 +686,14 @@ def _fatal_error(self, exc, message='Fatal error on transport'): self._transport._force_close(exc) def _finalize(self): + self._sslpipe = None + if self._transport is not None: self._transport.close() def _abort(self): - if self._transport is not None: - try: + try: + if self._transport is not None: self._transport.abort() - finally: - self._finalize() + finally: + self._finalize() diff --git a/Misc/NEWS b/Misc/NEWS index 7bd46d5578750e..213a6e9c2f6442 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -49,6 +49,9 @@ Core and Builtins Library ------- +- bpo-29870: Fix ssl sockets leaks when connection is aborted in asyncio/ssl + implementation. Patch by Michaël Sghaïer. + - bpo-29743: Closing transport during handshake process leaks open socket. Patch by Nikolay Kim