Skip to content

Commit f39a5cd

Browse files
committed
gh-142352: pause transport before moving buffered data
Move pause_reading() ahead of the StreamReader buffer handoff in BaseEventLoop.start_tls() for clearer sequencing.
1 parent d3d9940 commit f39a5cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/asyncio/base_events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,10 @@ async def start_tls(self, transport, protocol, sslcontext, *,
13411341
ssl_shutdown_timeout=ssl_shutdown_timeout,
13421342
call_connection_made=False)
13431343

1344+
# Pause early so that "ssl_protocol.data_received()" doesn't
1345+
# have a chance to get called before "ssl_protocol.connection_made()".
1346+
transport.pause_reading()
1347+
13441348
# gh-142352: move buffered StreamReader data to SSLProtocol
13451349
if server_side:
13461350
stream_reader = getattr(protocol, '_stream_reader', None)
@@ -1350,10 +1354,6 @@ async def start_tls(self, transport, protocol, sslcontext, *,
13501354
ssl_protocol._incoming.write(buffer)
13511355
buffer.clear()
13521356

1353-
# Pause early so that "ssl_protocol.data_received()" doesn't
1354-
# have a chance to get called before "ssl_protocol.connection_made()".
1355-
transport.pause_reading()
1356-
13571357
transport.set_protocol(ssl_protocol)
13581358
conmade_cb = self.call_soon(ssl_protocol.connection_made, transport)
13591359
resume_cb = self.call_soon(transport.resume_reading)

0 commit comments

Comments
 (0)