aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-30 13:29:39 +0200
committerGitHub <[email protected]>2022-03-30 13:29:39 +0200
commiteadcc2257cd8cd94c02bbbc5d2a8cd11a53fb928 (patch)
treef4291fcdb204e434abaab0e43b4d22b1d877156f /zenserver/cache/structuredcachestore.cpp
parentMerge pull request #64 from EpicGames/de/fix-cachebucket-gatherreferences (diff)
parentcleanup (diff)
downloadzen-eadcc2257cd8cd94c02bbbc5d2a8cd11a53fb928.tar.xz
zen-eadcc2257cd8cd94c02bbbc5d2a8cd11a53fb928.zip
Merge pull request #67 from EpicGames/de/cache-lock-fixes
de/cache lock fixes
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 66f32c858..cf066fb0e 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -249,11 +249,9 @@ ZenCacheMemoryLayer::Put(std::string_view InBucket, const IoHash& HashKey, const
{
RwLock::SharedLockScope _(m_Lock);
- auto it = m_Buckets.find(std::string(InBucket));
-
- if (it != m_Buckets.end())
+ if (auto It = m_Buckets.find(std::string(InBucket)); It != m_Buckets.end())
{
- Bucket = &it->second;
+ Bucket = &It->second;
}
}
@@ -263,7 +261,14 @@ ZenCacheMemoryLayer::Put(std::string_view InBucket, const IoHash& HashKey, const
RwLock::ExclusiveLockScope _(m_Lock);
- Bucket = &m_Buckets[std::string(InBucket)];
+ if (auto It = m_Buckets.find(std::string(InBucket)); It != m_Buckets.end())
+ {
+ Bucket = &It->second;
+ }
+ else
+ {
+ Bucket = &m_Buckets[std::string(InBucket)];
+ }
}
// Note that since the underlying IoBuffer is retained, the content type is also
@@ -757,7 +762,7 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx)
const GcClock::Tick ExpireTicks = ExpireTime.time_since_epoch().count();
- RwLock::ExclusiveLockScope _(m_IndexLock);
+ RwLock::SharedLockScope _(m_IndexLock);
std::vector<IoHash> ValidKeys;
std::vector<IoHash> ExpiredKeys;