From 7f1cd726c6e2d20368fe4d6a9762556c6d3604c2 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Fri, 9 Jun 2017 19:14:24 -0400 Subject: [PATCH] Break circular references when closing SSLTransport objects (#981) (#2048) --- 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 31803ac3b0dc..61d478ebda6c 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -685,12 +685,14 @@ class SSLProtocol(protocols.Protocol): 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 05331939f6ef..5edf13b98cdb 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -56,6 +56,9 @@ Extension Modules 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 -- 2.47.3