summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-06-09 22:27:45 (GMT)
committerGitHub <noreply@github.com>2017-06-09 22:27:45 (GMT)
commitff9511bbadba27457cd0eb084e9b4305ab9dfcf5 (patch)
tree38a32487fe4a2a068b252eca6303b3ddc0fdc7d8 /Lib/test
parenta0338045dbaa6c9f922113c6e9efad6bdbc4cdcb (diff)
downloadcpython-ff9511bbadba27457cd0eb084e9b4305ab9dfcf5.zip
cpython-ff9511bbadba27457cd0eb084e9b4305ab9dfcf5.tar.gz
cpython-ff9511bbadba27457cd0eb084e9b4305ab9dfcf5.tar.bz2
Closing transport during handshake process leaks socket (#480) (#2045)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_sslproto.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py
index f1771c5..bcd236e 100644
--- a/Lib/test/test_asyncio/test_sslproto.py
+++ b/Lib/test/test_asyncio/test_sslproto.py
@@ -42,6 +42,7 @@ class SslProtoHandshakeTests(test_utils.TestCase):
sslpipe.do_handshake.side_effect = mock_handshake
with mock.patch('asyncio.sslproto._SSLPipe', return_value=sslpipe):
ssl_proto.connection_made(transport)
+ return transport
def test_cancel_handshake(self):
# Python issue #23197: cancelling a handshake must not raise an
@@ -95,6 +96,20 @@ class SslProtoHandshakeTests(test_utils.TestCase):
test_utils.run_briefly(self.loop)
self.assertIsInstance(waiter.exception(), ConnectionAbortedError)
+ def test_close_during_handshake(self):
+ # bpo-29743 Closing transport during handshake process leaks socket
+ waiter = asyncio.Future(loop=self.loop)
+ ssl_proto = self.ssl_protocol(waiter)
+
+ def do_handshake(callback):
+ return []
+
+ transport = self.connection_made(ssl_proto)
+ test_utils.run_briefly(self.loop)
+
+ ssl_proto._app_transport.close()
+ self.assertTrue(transport.abort.called)
+
def test_get_extra_info_on_closed_connection(self):
waiter = asyncio.Future(loop=self.loop)
ssl_proto = self.ssl_protocol(waiter)