aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-24 13:24:51 +0200
committerDan Engelbrecht <[email protected]>2022-05-24 13:24:51 +0200
commit898a48b5121ed09879e34dc3315387d927a91ebf (patch)
tree89da039ef11705b93aa5200496054ee0ea6f0f94 /zenserver/cache/structuredcachestore.cpp
parentMerge pull request #102 from EpicGames/de/auto-create-namespaces (diff)
downloadzen-898a48b5121ed09879e34dc3315387d927a91ebf.tar.xz
zen-898a48b5121ed09879e34dc3315387d927a91ebf.zip
Make sure to hold exclusive lock over index and all shard locks.
Clear index on drop.
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 3189a14cc..1db99280e 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -1199,8 +1199,16 @@ ZenCacheDiskLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue&
void
ZenCacheDiskLayer::CacheBucket::Drop()
{
+ RwLock::ExclusiveLockScope _(m_IndexLock);
+ std::vector<std::unique_ptr<RwLock::ExclusiveLockScope>> ShardLocks;
+ ShardLocks.reserve(256);
+ for (RwLock& Lock : m_ShardedLocks)
+ {
+ ShardLocks.push_back(std::make_unique<RwLock::ExclusiveLockScope>(Lock));
+ }
m_BlockStore.Close();
m_SlogFile.Close();
+ m_Index.clear();
DeleteDirectories(m_BucketDir);
}
@@ -2274,7 +2282,7 @@ ZenCacheStore::GetNamespace(std::string_view Namespace)
void
ZenCacheStore::IterateNamespaces(const std::function<void(std::string_view Namespace, ZenCacheNamespace& Store)>& Callback) const
{
- std::vector<std::pair<std::string, ZenCacheNamespace&> > Namespaces;
+ std::vector<std::pair<std::string, ZenCacheNamespace&>> Namespaces;
{
RwLock::SharedLockScope _(m_NamespacesLock);
Namespaces.reserve(m_Namespaces.size());