]> granicus.if.org Git - python/commitdiff
bpo-33674: Pause the transport as early as possible (#7192)
authorYury Selivanov <yury@magic.io>
Tue, 29 May 2018 05:00:12 +0000 (01:00 -0400)
committerGitHub <noreply@github.com>
Tue, 29 May 2018 05:00:12 +0000 (01:00 -0400)
Lib/asyncio/base_events.py
Misc/NEWS.d/next/Library/2018-05-29-00-37-56.bpo-33674.2IkGhL.rst [new file with mode: 0644]

index ffd2513e33a6a07a513b80d233699734c0f6a246..61938e90c375dfb3a8f51475f685b93e808e4fc5 100644 (file)
@@ -1106,10 +1106,13 @@ class BaseEventLoop(events.AbstractEventLoop):
             ssl_handshake_timeout=ssl_handshake_timeout,
             call_connection_made=False)
 
+        # Pause early so that "ssl_protocol.data_received()" doesn't
+        # have a chance to get called before "ssl_protocol.connection_made()".
+        transport.pause_reading()
+
         transport.set_protocol(ssl_protocol)
         self.call_soon(ssl_protocol.connection_made, transport)
-        if not transport.is_reading():
-            self.call_soon(transport.resume_reading)
+        self.call_soon(transport.resume_reading)
 
         await waiter
         return ssl_protocol._app_transport
diff --git a/Misc/NEWS.d/next/Library/2018-05-29-00-37-56.bpo-33674.2IkGhL.rst b/Misc/NEWS.d/next/Library/2018-05-29-00-37-56.bpo-33674.2IkGhL.rst
new file mode 100644 (file)
index 0000000..66baca1
--- /dev/null
@@ -0,0 +1,2 @@
+Pause the transport as early as possible to further reduce the risk of
+data_received() being called before connection_made().