Skip to content

Commit

Permalink
Write frames in chunks smaller than 2GB
Browse files Browse the repository at this point in the history
Works around the same OpenSSL issue seen for reading except this does so
for writing. As individual frames may not be this large, this may be
less of an issue. Still this is a good preventative measure to protect
users.
  • Loading branch information
jakirkham committed Jul 28, 2021
1 parent 1b974d0 commit b698031
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,13 @@ async def write(self, msg, serializers=None, on_error="message"):
# See <https://github.com/tornadoweb/tornado/pull/2996>
each_frame = each_frame.cast("B")

stream._write_buffer.append(each_frame)
stream._total_write_index += each_frame_nbytes
# Workaround for OpenSSL 1.0.2 (can drop with OpenSSL 1.1.1)
for i, j in sliding_window(
2, range(0, each_frame_nbytes + C_INT_MAX, C_INT_MAX)
):
chunk = each_frame[i:j]
stream._write_buffer.append(chunk)
stream._total_write_index += chunk.nbytes

# start writing frames
stream.write(b"")
Expand Down

0 comments on commit b698031

Please sign in to comment.