1
0
Fork 0
forked from lthn/blockchain

basic_db_accessor: fixed a bug in close()

This commit is contained in:
sowle 2019-11-14 06:03:24 +03:00
parent cd1e3c115d
commit 320249f1f6
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC

View file

@ -89,8 +89,11 @@ namespace tools
mutable performance_data m_gperformance_data; mutable performance_data m_gperformance_data;
mutable std::unordered_map<container_handle, performance_data> m_performance_data_map; mutable std::unordered_map<container_handle, performance_data> m_performance_data_map;
public: public:
basic_db_accessor(std::shared_ptr<i_db_backend> backend, epee::shared_recursive_mutex& rwlock) :m_backend(backend), m_rwlock(rwlock), m_is_open(false) basic_db_accessor(std::shared_ptr<i_db_backend> backend, epee::shared_recursive_mutex& rwlock)
{} : m_backend(backend), m_rwlock(rwlock), m_is_open(false)
{
}
~basic_db_accessor() ~basic_db_accessor()
{ {
close(); close();
@ -239,8 +242,11 @@ namespace tools
bool close() bool close()
{ {
m_is_open = false; m_is_open = false;
if (!m_backend)
return true;
return m_backend->close(); return m_backend->close();
} }
bool open(const std::string& path, uint64_t cache_sz = CACHE_SIZE) bool open(const std::string& path, uint64_t cache_sz = CACHE_SIZE)
{ {
bool r = m_backend->open(path, cache_sz); bool r = m_backend->open(path, cache_sz);