Skip to content

Commit 3ab8bae

Browse files
committed
Make sure no data is lost when there is not enough data in the buffer to read a segment
1 parent 1de685b commit 3ab8bae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cassandra/connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,9 @@ def _process_segment_buffer(self):
11221122
segment = self._segment_codec.decode(self._iobuf, segment_header)
11231123
self._io_buffer.cql_frame_buffer.write(segment.payload)
11241124
else:
1125-
# not enough data to read the segment
1126-
self._io_buffer.io_buffer.seek(0, 2)
1125+
# not enough data to read the segment. reset the buffer pointer at the
1126+
# beginning to not lose what we previously read (header).
1127+
self._io_buffer.io_buffer.seek(0)
11271128
except CrcException as exc:
11281129
# re-raise an exception that inherits from ConnectionException
11291130
raise CrcMismatchException(str(exc), self.endpoint)

0 commit comments

Comments
 (0)