bpo-33674: asyncio: Fix SSLProtocol race (GH-7175) (GH-7188) · python/cpython@7593b8a

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -574,7 +574,7 @@ def _start_handshake(self):

574574

# (b'', 1) is a special value in _process_write_backlog() to do

575575

# the SSL handshake

576576

self._write_backlog.append((b'', 1))

577-

self._loop.call_soon(self._process_write_backlog)

577+

self._process_write_backlog()

578578
579579

def _on_handshake_complete(self, handshake_exc):

580580

self._in_handshake = False

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,4 @@

1+

Fix a race condition in SSLProtocol.connection_made() of asyncio.sslproto:

2+

start immediately the handshake instead of using call_soon(). Previously,

3+

data_received() could be called before the handshake started, causing the

4+

handshake to hang or fail.