Skip to content

Commit 8f5cdb6

Browse files
committed
Report errors if reading from a cache reader fails.
If we can't read the cached page, don't just return junk data.
1 parent 90a17af commit 8f5cdb6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

reader.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ CacheReader::Page::load(const Reader &r, Off offset_)
119119
{
120120
assert(offset_ % data.size() == 0);
121121
len = r.read(offset_, data.size(), data.data());
122+
if (len != data.size())
123+
throw (Exception() << "failed to read page");
122124
offset = offset_;
123125
}
124126

@@ -157,9 +159,9 @@ CacheReader::getPage(Off pageoff) const
157159
} else {
158160
p = std::make_unique<Page>();
159161
}
160-
p->load(*upstream, pageoff);
161-
pages.push_front(std::move(p));
162-
return **pages.begin();
162+
p->load(*upstream, pageoff);
163+
pages.push_front(std::move(p));
164+
return **pages.begin();
163165
}
164166

165167
size_t

0 commit comments

Comments
 (0)