8000 bpo-33674: Pause the transport as early as possible (GH-7192) · python/cpython@eca0859 · GitHub
[go: up one dir, main page]

Skip to content

Commit eca0859

Browse files
miss-islington1st1
andauthored
bpo-33674: Pause the transport as early as possible (GH-7192)
(cherry picked from commit f295587) Co-authored-by: Yury Selivanov <yury@magic.io>
1 parent 78e14f8 commit eca0859

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Lib/asyncio/base_events.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,13 @@ async def start_tls(self, transport, protocol, sslcontext, *,
11061106
ssl_handshake_timeout=ssl_handshake_timeout,
11071107
call_connection_made=False)
11081108

1109+
# Pause early so that "ssl_protocol.data_received()" doesn't
1110+
# have a chance to get called before "ssl_protocol.connection_made()".
1111+
transport.pause_reading()
1112+
11091113
transport.set_protocol(ssl_protocol)
11101114
self.call_soon(ssl_protocol.connection_made, transport)
1111-
if not transport.is_reading():
1112-
self.call_soon(transport.resume_reading)
1115+
self.call_soon(transport.resume_reading)
11131116

11141117
await waiter
11151118
return ssl_protocol._app_transport
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Pause the transport as early as possible to further reduce the risk of
2+
data_received() being called before connection_made().

0 commit comments

Comments
 (0)
0