8000 bpo-33674: asyncio: Fix SSLProtocol race (GH-7175) · python/cpython@be00a55 · GitHub
[go: up one dir, main page]

Skip to content

Commit be00a55

Browse files
authored
bpo-33674: asyncio: Fix SSLProtocol race (GH-7175)
Fix a race condition in SSLProtocol.connection_made() of asyncio.sslproto: start immediately the handshake instead of using call_soon(). Previously, data_received() could be called before the handshake started, causing the handshake to hang or fail.
1 parent 8c1ad0c commit be00a55

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/asyncio/sslproto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,10 @@ def _start_handshake(self):
592592
# (b'', 1) is a special value in _process_write_backlog() to do
593593
# the SSL handshake
594594
self._write_backlog.append((b'', 1))
595-
self._loop.call_soon(self._process_write_backlog)
596595
self._handshake_timeout_handle = \
597596
self._loop.call_later(self._ssl_handshake_timeout,
598597
self._check_handshake_timeout)
598+
self._process_write_backlog()
599599

600600
def _check_handshake_timeout(self):
601601
if self._in_handshake is True:
Lines changed: 4 additions & 0 deletions
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.

0 commit comments

Comments
 (0)
0