Pause accepted transport before scheduling TLS handshake

This commit is contained in:
2026-11-13 12:51:57 +03:00
parent 9c1da003f0
commit 0bf1ff93c7
+6
View File
@@ -77,6 +77,12 @@ async def serve(routes):
if peer: peer.close()
def accept(reader, writer, route):
# connection_made calls this synchronously. Pause before scheduling the
# coroutine: otherwise StreamReader can consume ClientHello while that
# coroutine waits in the event-loop queue. start_tls resumes the transport
# after installing SSLProtocol. Outgoing local plaintext is unaffected.
if route['mode'] == 'server':
writer.transport.pause_reading()
if len(tasks) >= 96:
writer.close(); return
task = asyncio.create_task(handle(reader, writer, route))