From de58d08e599565cb62a86d869ef3b19182e656d5 Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Tue, 7 Apr 2015 00:25:54 +0300 Subject: [PATCH] sstable: fix compressed data file stream bug We need to update _pos after we read, or we keep reading the same chunk over and over :-( Also, don't read anything if we're already past the end of file. Signed-off-by: Nadav Har'El --- sstables/compress.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sstables/compress.cc b/sstables/compress.cc index fdf62a05c4..ecbe7ef15c 100644 --- a/sstables/compress.cc +++ b/sstables/compress.cc @@ -154,6 +154,9 @@ public: _pos(pos) {} virtual future> get() override { + if (_pos >= _compression_metadata->data_len) { + return make_ready_future>(); + } auto addr = _compression_metadata->locate(_pos); return read_exactly(_file, addr.chunk_start, addr.chunk_len). then([this, addr](temporary_buffer buf) { @@ -182,6 +185,7 @@ public: out.get_write(), out.size()); out.trim(len); out.trim_front(addr.offset); + _pos += out.size(); return out; }); }