Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit d84a8cb

Browse files
HoHo-Hogvanrossum
authored andcommitted
SSL hangs if connection_lost is called (#472) (#476)
There were situations when yield from waiter hangs. For example if connection is aborted by peer before handshake completes.
1 parent 3878fa8 commit d84a8cb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

asyncio/sslproto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ def connection_lost(self, exc):
479479
self._loop.call_soon(self._app_protocol.connection_lost, exc)
480480
self._transport = None
481481
self._app_transport = None
482+
self._wakeup_waiter(exc)
482483

483484
def pause_writing(self):
484485
"""Called when the low-level transport's buffer goes over

tests/test_sslproto.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,15 @@ def test_fatal_error_no_name_error(self):
8585
# Restore error logging.
8686
log.logger.setLevel(log_level)
8787

88+
def test_connection_lost(self):
89+
# From issue #472.
90+
# yield from waiter hang if lost_connection was called.
91+
waiter = asyncio.Future(loop=self.loop)
92+
ssl_proto = self.ssl_protocol(waiter)
93+
self.connection_made(ssl_proto)
94+
ssl_proto.connection_lost(ConnectionAbortedError)
95+
test_utils.run_briefly(self.loop)
96+
self.assertIsInstance(waiter.exception(), ConnectionAbortedError)
97+
8898
if __name__ == '__main__':
8999
unittest.main()

0 commit comments

Comments
 (0)