Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bytearray buffers in IOStream #1873

Merged
merged 8 commits into from Feb 21, 2017

Fix handling _write_buffer_frozen

  • Loading branch information...
pitrou committed Nov 1, 2016
commit 70b075f6aab9f61387d44cc1214f74bf7cabd856
@@ -820,17 +820,19 @@ def _handle_write(self):
while self._write_buffer_size:
try:
start = self._write_buffer_pos
if _WINDOWS:
if self._write_buffer_frozen:
size = self._write_buffer_frozen
elif _WINDOWS:
# On windows, socket.send blows up if given a
# write buffer that's too large, instead of just
# returning the number of bytes it was able to
# process. Therefore we must not call socket.send
# with more than 128KB at a time.
stop = start + 128 * 1024
size = 128 * 1024
else:
stop = None
size = self._write_buffer_size
num_bytes = self.write_to_fd(
memoryview(self._write_buffer)[start:stop])
memoryview(self._write_buffer)[start:start + size])
assert self._write_buffer_size >= 0
if num_bytes == 0:
# With OpenSSL, if we couldn't write the entire buffer,
@@ -841,7 +843,7 @@ def _handle_write(self):
# SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, but this is
# not yet accessible from python
# (http://bugs.python.org/issue8240)
self._write_buffer_frozen = True
self._write_buffer_frozen = size
break
self._write_buffer_frozen = False
self._write_buffer_pos += num_bytes
@@ -852,7 +854,7 @@ def _handle_write(self):
self._write_buffer_pos = 0
except (socket.error, IOError, OSError) as e:
if e.args[0] in _ERRNO_WOULDBLOCK:
self._write_buffer_frozen = True
self._write_buffer_frozen = size
break
else:
if not self._is_connreset(e):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.