Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filter_policy object leak in NodeStore backends #484

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/ripple/nodestore/backend/HyperDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class HyperDBBackend
Scheduler& m_scheduler;
BatchWriter m_batch;
std::string m_name;
std::unique_ptr <hyperleveldb::FilterPolicy const> m_filter_policy;
std::unique_ptr <hyperleveldb::DB> m_db;

HyperDBBackend (size_t keyBytes, Parameters const& keyValues,
Expand Down Expand Up @@ -63,12 +64,13 @@ class HyperDBBackend
if (keyValues ["filter_bits"].isEmpty())
{
if (getConfig ().NODE_SIZE >= 2)
options.filter_policy = hyperleveldb::NewBloomFilterPolicy (10);
m_filter_policy.reset (hyperleveldb::NewBloomFilterPolicy (10));
}
else if (keyValues ["filter_bits"].getIntValue() != 0)
{
options.filter_policy = hyperleveldb::NewBloomFilterPolicy (keyValues ["filter_bits"].getIntValue ());
m_filter_policy.reset (hyperleveldb::NewBloomFilterPolicy (keyValues ["filter_bits"].getIntValue ()));
}
options.filter_policy = m_filter_policy.get();

if (! keyValues["open_files"].isEmpty ())
{
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/nodestore/backend/LevelDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LevelDBBackend
Scheduler& m_scheduler;
BatchWriter m_batch;
std::string m_name;
std::unique_ptr <leveldb::FilterPolicy const> m_filter_policy;
std::unique_ptr <leveldb::DB> m_db;

LevelDBBackend (int keyBytes, Parameters const& keyValues,
Expand Down Expand Up @@ -63,12 +64,13 @@ class LevelDBBackend
if (keyValues["filter_bits"].isEmpty())
{
if (getConfig ().NODE_SIZE >= 2)
options.filter_policy = leveldb::NewBloomFilterPolicy (10);
m_filter_policy.reset (leveldb::NewBloomFilterPolicy (10));
}
else if (keyValues["filter_bits"].getIntValue() != 0)
{
options.filter_policy = leveldb::NewBloomFilterPolicy (keyValues["filter_bits"].getIntValue());
m_filter_policy.reset (leveldb::NewBloomFilterPolicy (keyValues["filter_bits"].getIntValue()));
}
options.filter_policy = m_filter_policy.get();

if (! keyValues["open_files"].isEmpty())
{
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/nodestore/backend/RocksDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class RocksDBBackend
Scheduler& m_scheduler;
BatchWriter m_batch;
std::string m_name;
std::unique_ptr <rocksdb::FilterPolicy const> m_filter_policy;
std::unique_ptr <rocksdb::DB> m_db;

RocksDBBackend (int keyBytes, Parameters const& keyValues,
Expand Down Expand Up @@ -114,12 +115,13 @@ class RocksDBBackend
if (keyValues["filter_bits"].isEmpty())
{
if (getConfig ().NODE_SIZE >= 2)
options.filter_policy = rocksdb::NewBloomFilterPolicy (10);
m_filter_policy.reset (rocksdb::NewBloomFilterPolicy (10));
}
else if (keyValues["filter_bits"].getIntValue() != 0)
{
options.filter_policy = rocksdb::NewBloomFilterPolicy (keyValues["filter_bits"].getIntValue());
m_filter_policy.reset (rocksdb::NewBloomFilterPolicy (keyValues["filter_bits"].getIntValue()));
}
options.filter_policy = m_filter_policy.get();

if (! keyValues["open_files"].isEmpty())
{
Expand Down