bpo-33674: Pause the transport as early as possible (GH-7192)

(cherry picked from commit f295587c45)

Co-authored-by: Yury Selivanov <yury@magic.io>
This commit is contained in:
Miss Islington (bot) 2018-05-28 22:59:03 -07:00 committed by GitHub
parent 78e14f8eb4
commit eca085993c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View 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

View File

@ -0,0 +1,2 @@
Pause the transport as early as possible to further reduce the risk of
data_received() being called before connection_made().