]> granicus.if.org Git - python/commitdiff
bpo-33674: asyncio: Fix SSLProtocol race (GH-7175) (GH-7188)
authorVictor Stinner <vstinner@redhat.com>
Tue, 29 May 2018 04:46:48 +0000 (06:46 +0200)
committerYury Selivanov <yury@magic.io>
Tue, 29 May 2018 04:46:48 +0000 (00:46 -0400)
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 be00a5583a2cb696335c527b921d1868266a42c6)

Lib/asyncio/sslproto.py
Misc/NEWS.d/next/Library/2018-05-28-22-49-59.bpo-33674.6LFFj7.rst [new file with mode: 0644]

index a82babb6b9e245b1b3b6217c677ca75e3b91b749..367f7d07a4184a302b5705e7223037407bb9e7f8 100644 (file)
@@ -574,7 +574,7 @@ 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._process_write_backlog()
 
     def _on_handshake_complete(self, handshake_exc):
         self._in_handshake = False
diff --git a/Misc/NEWS.d/next/Library/2018-05-28-22-49-59.bpo-33674.6LFFj7.rst b/Misc/NEWS.d/next/Library/2018-05-28-22-49-59.bpo-33674.6LFFj7.rst
new file mode 100644 (file)
index 0000000..1e98680
--- /dev/null
@@ -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.