summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/sslproto.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-07 22:25:52 (GMT)
committerGitHub <noreply@github.com>2018-06-07 22:25:52 (GMT)
commit79790bc35fe722a49977b52647f9b5fe1deda2b7 (patch)
treeb1b3da290ccfb7055c94e937cd1edc0282bf7a38 /Lib/asyncio/sslproto.py
parentd3ed67d14ed401dfe2b5d07b6941adc3ecacb268 (diff)
downloadcpython-79790bc35fe722a49977b52647f9b5fe1deda2b7.zip
cpython-79790bc35fe722a49977b52647f9b5fe1deda2b7.tar.gz
cpython-79790bc35fe722a49977b52647f9b5fe1deda2b7.tar.bz2
bpo-33694: Fix race condition in asyncio proactor (GH-7498)
The cancellation of an overlapped WSARecv() has a race condition which causes data loss because of the current implementation of proactor in asyncio. No longer cancel overlapped WSARecv() in _ProactorReadPipeTransport to work around the race condition. Remove the optimized recv_into() implementation to get simple implementation of pause_reading() using the single _pending_data attribute. Move _feed_data_to_bufferred_proto() to protocols.py. Remove set_protocol() method which became useless.
Diffstat (limited to 'Lib/asyncio/sslproto.py')
-rw-r--r--Lib/asyncio/sslproto.py21
1 files changed, 1 insertions, 20 deletions
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py
index fac2ae7..5578c6f 100644
--- a/Lib/asyncio/sslproto.py
+++ b/Lib/asyncio/sslproto.py
@@ -535,7 +535,7 @@ class SSLProtocol(protocols.Protocol):
if chunk:
try:
if self._app_protocol_is_buffer:
- _feed_data_to_bufferred_proto(
+ protocols._feed_data_to_bufferred_proto(
self._app_protocol, chunk)
else:
self._app_protocol.data_received(chunk)
@@ -721,22 +721,3 @@ class SSLProtocol(protocols.Protocol):
self._transport.abort()
finally:
self._finalize()
-
-
-def _feed_data_to_bufferred_proto(proto, data):
- data_len = len(data)
- while data_len:
- buf = proto.get_buffer(data_len)
- buf_len = len(buf)
- if not buf_len:
- raise RuntimeError('get_buffer() returned an empty buffer')
-
- if buf_len >= data_len:
- buf[:data_len] = data
- proto.buffer_updated(data_len)
- return
- else:
- buf[:buf_len] = data[:buf_len]
- proto.buffer_updated(buf_len)
- data = data[buf_len:]
- data_len = len(data)