aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/cachememorylayer.cpp
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/zenserver/cache/cachememorylayer.cpp
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/zenserver/cache/cachememorylayer.cpp')
-rw-r--r--src/zenserver/cache/cachememorylayer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/zenserver/cache/cachememorylayer.cpp b/src/zenserver/cache/cachememorylayer.cpp
index d48ee5aa8..cae3b457e 100644
--- a/src/zenserver/cache/cachememorylayer.cpp
+++ b/src/zenserver/cache/cachememorylayer.cpp
@@ -404,7 +404,7 @@ ZenCacheMemoryLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue
BucketPayload& Payload = m_Payloads[EntryIndex];
OldPayloadSize = Payload.Payload.GetSize();
- Payload.Payload = Value.Value;
+ Payload.Payload = IoBufferBuilder::ReadFromFileMaybe(Value.Value);
Payload.RawHash = Value.RawHash;
Payload.RawSize = gsl::narrow<uint32_t>(Value.RawSize);
m_AccessTimes[EntryIndex] = AccessTime;
@@ -417,8 +417,9 @@ ZenCacheMemoryLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue
else
{
uint32_t EntryIndex = gsl::narrow<uint32_t>(m_Payloads.size());
- m_Payloads.emplace_back(
- BucketPayload{.Payload = Value.Value, .RawSize = gsl::narrow<uint32_t>(Value.RawSize), .RawHash = Value.RawHash});
+ m_Payloads.emplace_back(BucketPayload{.Payload = IoBufferBuilder::ReadFromFileMaybe(Value.Value),
+ .RawSize = gsl::narrow<uint32_t>(Value.RawSize),
+ .RawHash = Value.RawHash});
m_AccessTimes.emplace_back(AccessTime);
m_CacheMap.insert_or_assign(HashKey, EntryIndex);
}