Commit 99c23cf1 authored by Max Kellermann's avatar Max Kellermann

Instance: eliminate ShutdownDatabase(), move code to destructor

Destruct automatically, even if leaving the scope due to exception being thrown.
parent 9aa75e73
......@@ -30,6 +30,8 @@
#ifdef ENABLE_DATABASE
#include "db/DatabaseError.hxx"
#include "db/Interface.hxx"
#include "storage/StorageInterface.hxx"
#ifdef ENABLE_SQLITE
#include "sticker/StickerDatabase.hxx"
......@@ -48,7 +50,17 @@ Instance::Instance()
{
}
Instance::~Instance() noexcept = default;
Instance::~Instance() noexcept
{
#ifdef ENABLE_DATABASE
if (database != nullptr) {
database->Close();
delete database;
}
delete storage;
#endif
}
Partition *
Instance::FindPartition(const char *name) noexcept
......
......@@ -168,7 +168,6 @@ struct Instance final
void BeginShutdownUpdate() noexcept;
void FinishShutdownUpdate() noexcept;
void ShutdownDatabase() noexcept;
#ifdef ENABLE_CURL
void LookupRemoteTag(const char *uri) noexcept;
......
......@@ -360,19 +360,6 @@ Instance::FinishShutdownUpdate() noexcept
}
inline void
Instance::ShutdownDatabase() noexcept
{
#ifdef ENABLE_DATABASE
if (instance->database != nullptr) {
instance->database->Close();
delete instance->database;
}
delete instance->storage;
#endif
}
inline void
Instance::BeginShutdownPartitions() noexcept
{
for (auto &partition : partitions) {
......@@ -648,7 +635,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
#endif
instance->FinishShutdownUpdate();
instance->ShutdownDatabase();
#ifdef ENABLE_SQLITE
sticker_global_finish();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment