aboutsummaryrefslogtreecommitdiff
path: root/src/zencore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-10-05 16:45:45 +0200
committerGitHub <[email protected]>2023-10-05 16:45:45 +0200
commit9d8d68661205e955bf096f84f27c7e23bba5187a (patch)
treea4ebf0273a8245ffafb737fc3ecc536d6d98f28f /src/zencore
parentfixed issue where IoBufferBuilder::ReadFromFileMaybe loses content type (#450) (diff)
downloadzen-9d8d68661205e955bf096f84f27c7e23bba5187a.tar.xz
zen-9d8d68661205e955bf096f84f27c7e23bba5187a.zip
ZenCacheMemoryLayer should always store values using memory buffers (#451)
this change fixes a problem where the memory cache layer can inadvertently prevent underlying block store files from being deleted * ensure we get memory buffers on all paths * added more context to error in IoBufferBuilder::ReadFromFileMaybe * fixed problematic pread call success check in IoBufferBuilder::ReadFromFileMaybe which would always report failure on Linux/MacOS
Diffstat (limited to 'src/zencore')
-rw-r--r--src/zencore/iobuffer.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/zencore/iobuffer.cpp b/src/zencore/iobuffer.cpp
index 82ead42f0..9043d4d4c 100644
--- a/src/zencore/iobuffer.cpp
+++ b/src/zencore/iobuffer.cpp
@@ -557,14 +557,17 @@ IoBufferBuilder::ReadFromFileMaybe(const IoBuffer& InBuffer)
#else
int Fd = int(intptr_t(FileRef.FileHandle));
int Result = pread(Fd, OutBuffer.MutableData(), size_t(FileRef.FileChunkSize), off_t(FileRef.FileChunkOffset));
- bool Success = (Result < 0);
+ bool Success = (Result >= 0);
uint32_t dwNumberOfBytesRead = uint32_t(Result);
#endif
if (!Success)
{
- ThrowLastError("ReadFile failed in IoBufferBuilder::ReadFromFileMaybe");
+ ThrowLastError(fmt::format("file read failed in IoBufferBuilder::ReadFromFileMaybe (handle: {}, offset: {}, length: {})",
+ intptr_t(FileRef.FileHandle),
+ FileRef.FileChunkOffset,
+ FileRef.FileChunkSize));
}
ZEN_ASSERT(dwNumberOfBytesRead == FileRef.FileChunkSize);