Skip to content

Commit

Permalink
fix: use db when it has been opened (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 authored Feb 19, 2020
1 parent b9d632a commit b8b0c8f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,14 @@ void pegasus_server_impl::parse_checkpoints()
}
}

pegasus_server_impl::~pegasus_server_impl() = default;
pegasus_server_impl::~pegasus_server_impl()
{
if (_is_open) {
dassert(_db != nullptr, "");
delete _db;
_db = nullptr;
}
}

void pegasus_server_impl::gc_checkpoints(bool force_reserve_one)
{
Expand Down Expand Up @@ -1665,8 +1672,10 @@ ::dsn::error_code pegasus_server_impl::start(int argc, char **argv)

void pegasus_server_impl::cancel_background_work(bool wait)
{
dassert(_db != nullptr, "");
rocksdb::CancelAllBackgroundWork(_db, wait);
if (_is_open) {
dassert(_db != nullptr, "");
rocksdb::CancelAllBackgroundWork(_db, wait);
}
}

::dsn::error_code pegasus_server_impl::stop(bool clear_state)
Expand Down

0 comments on commit b8b0c8f

Please sign in to comment.