0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 12:48:54 +02:00

ircd::db: Fix exclusion and lock option required for cache iteration.

This commit is contained in:
Jason Volk 2018-08-21 00:19:53 -07:00
parent 35a0f1ea51
commit 11f266aa37

View file

@ -6164,6 +6164,12 @@ void
ircd::db::for_each(const rocksdb::Cache &cache,
const cache_closure &closure)
{
// Due to the use of the global variables which are required when using a
// C-style callback for RocksDB, we have to make use of this function
// exclusive for different contexts.
static ctx::mutex mutex;
const std::lock_guard<decltype(mutex)> lock{mutex};
thread_local rocksdb::Cache *_cache;
_cache = const_cast<rocksdb::Cache *>(&cache);
@ -6172,6 +6178,7 @@ ircd::db::for_each(const rocksdb::Cache &cache,
_cache->ApplyToAllCacheEntries([]
(void *const data, const size_t charge)
noexcept
{
assert(_cache);
assert(_closure);
@ -6193,7 +6200,7 @@ ircd::db::for_each(const rocksdb::Cache &cache,
(*_closure)(slice(s), charge);
},
false);
true);
}
bool