bpo-33674: asyncio: Fix SSLProtocol race (GH-7175) (#7187)

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.
(cherry picked from commit be00a5583a)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
Miss Islington (bot) 2018-05-28 18:44:16 -07:00 committed by Ned Deily
parent 420092e255
commit 0dd8fd0358
2 changed files with 5 additions and 1 deletions

View file

@ -592,10 +592,10 @@ class SSLProtocol(protocols.Protocol):
# (b'', 1) is a special value in _process_write_backlog() to do
# the SSL handshake
self._write_backlog.append((b'', 1))
self._loop.call_soon(self._process_write_backlog)
self._handshake_timeout_handle = \
self._loop.call_later(self._ssl_handshake_timeout,
self._check_handshake_timeout)
self._process_write_backlog()
def _check_handshake_timeout(self):
if self._in_handshake is True:

View file

@ -0,0 +1,4 @@
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.