]> granicus.if.org Git - python/commitdiff
Issue #28990: Fix SSL hanging if connection is closed before handshake completed.
authorYury Selivanov <yury@magic.io>
Fri, 16 Dec 2016 16:50:41 +0000 (11:50 -0500)
committerYury Selivanov <yury@magic.io>
Fri, 16 Dec 2016 16:50:41 +0000 (11:50 -0500)
Lib/asyncio/sslproto.py
Lib/test/test_asyncio/test_sslproto.py
Misc/NEWS

index 804c5c30f136ba4a928ac4416c3ca9acbabab19b..c2c4b95fcbc8037024457706f0c77e898ac04024 100644 (file)
@@ -479,6 +479,7 @@ class SSLProtocol(protocols.Protocol):
             self._loop.call_soon(self._app_protocol.connection_lost, exc)
         self._transport = None
         self._app_transport = None
+        self._wakeup_waiter(exc)
 
     def pause_writing(self):
         """Called when the low-level transport's buffer goes over
index 0ca6d1bf2aabb1506be807517c17733220e3a8ef..59ff0f6967e5b5bbec3232a160d5c26d28986b79 100644 (file)
@@ -85,5 +85,15 @@ class SslProtoHandshakeTests(test_utils.TestCase):
             # Restore error logging.
             log.logger.setLevel(log_level)
 
+    def test_connection_lost(self):
+        # From issue #472.
+        # yield from waiter hang if lost_connection was called.
+        waiter = asyncio.Future(loop=self.loop)
+        ssl_proto = self.ssl_protocol(waiter)
+        self.connection_made(ssl_proto)
+        ssl_proto.connection_lost(ConnectionAbortedError)
+        test_utils.run_briefly(self.loop)
+        self.assertIsInstance(waiter.exception(), ConnectionAbortedError)
+
 if __name__ == '__main__':
     unittest.main()
index f16d207464b1ddef36e2f56f26e8d216520f8c1d..806a603b907dae847ba1a6513cb115ee1aefb28e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -485,6 +485,10 @@ Library
 - Issue #24142: Reading a corrupt config file left the parser in an
   invalid state.  Original patch by Florian Höch.
 
+- Issue #28990: Fix SSL hanging if connection is closed before handshake 
+  completed.
+  (Patch by HoHo-Ho)
+
 IDLE
 ----