Fix crash saving an RDB
Former-commit-id: 51c35f03a84f7ada0f150a1c3992df574ab89b95
This commit is contained in:
parent
902264efb7
commit
50060b4a13
@ -18,9 +18,10 @@ dictType dbStorageCacheType = {
|
||||
NULL /* val destructor */
|
||||
};
|
||||
|
||||
StorageCache::StorageCache(IStorage *storage)
|
||||
StorageCache::StorageCache(IStorage *storage, bool fCache)
|
||||
: m_spstorage(storage)
|
||||
{
|
||||
if (fCache)
|
||||
m_pdict = dictCreate(&dbStorageCacheType, nullptr);
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ const StorageCache *StorageCache::clone()
|
||||
{
|
||||
std::unique_lock<fastlock> ul(m_lock);
|
||||
// Clones never clone the cache
|
||||
StorageCache *cacheNew = new StorageCache(const_cast<IStorage*>(m_spstorage->clone()));
|
||||
StorageCache *cacheNew = new StorageCache(const_cast<IStorage*>(m_spstorage->clone()), false /*fCache*/);
|
||||
return cacheNew;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class StorageCache
|
||||
int m_collisionCount = 0;
|
||||
mutable fastlock m_lock {"StorageCache"};
|
||||
|
||||
StorageCache(IStorage *storage);
|
||||
StorageCache(IStorage *storage, bool fNoCache);
|
||||
|
||||
void cacheKey(sds key);
|
||||
void cacheKey(const char *rgchKey, size_t cchKey);
|
||||
@ -29,12 +29,7 @@ class StorageCache
|
||||
|
||||
public:
|
||||
static StorageCache *create(IStorageFactory *pfactory, int db, IStorageFactory::key_load_iterator fn, void *privdata) {
|
||||
StorageCache *cache = new StorageCache(nullptr);
|
||||
if (!pfactory->FSlow())
|
||||
{
|
||||
dictRelease(cache->m_pdict);
|
||||
cache->m_pdict = nullptr;
|
||||
}
|
||||
StorageCache *cache = new StorageCache(nullptr, pfactory->FSlow() /*fCache*/);
|
||||
load_iter_data data = {cache, fn, privdata};
|
||||
cache->m_spstorage = std::shared_ptr<IStorage>(pfactory->create(db, key_load_itr, (void*)&data));
|
||||
return cache;
|
||||
|
Loading…
x
Reference in New Issue
Block a user