Instance: eliminate ShutdownDatabase(), move code to destructor
Destruct automatically, even if leaving the scope due to exception being thrown.
This commit is contained in:
parent
9aa75e738c
commit
99c23cf139
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
#include "db/DatabaseError.hxx"
|
#include "db/DatabaseError.hxx"
|
||||||
|
#include "db/Interface.hxx"
|
||||||
|
#include "storage/StorageInterface.hxx"
|
||||||
|
|
||||||
#ifdef ENABLE_SQLITE
|
#ifdef ENABLE_SQLITE
|
||||||
#include "sticker/StickerDatabase.hxx"
|
#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 *
|
Partition *
|
||||||
Instance::FindPartition(const char *name) noexcept
|
Instance::FindPartition(const char *name) noexcept
|
||||||
|
@ -168,7 +168,6 @@ struct Instance final
|
|||||||
|
|
||||||
void BeginShutdownUpdate() noexcept;
|
void BeginShutdownUpdate() noexcept;
|
||||||
void FinishShutdownUpdate() noexcept;
|
void FinishShutdownUpdate() noexcept;
|
||||||
void ShutdownDatabase() noexcept;
|
|
||||||
|
|
||||||
#ifdef ENABLE_CURL
|
#ifdef ENABLE_CURL
|
||||||
void LookupRemoteTag(const char *uri) noexcept;
|
void LookupRemoteTag(const char *uri) noexcept;
|
||||||
|
14
src/Main.cxx
14
src/Main.cxx
@ -359,19 +359,6 @@ Instance::FinishShutdownUpdate() noexcept
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
Instance::ShutdownDatabase() noexcept
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_DATABASE
|
|
||||||
if (instance->database != nullptr) {
|
|
||||||
instance->database->Close();
|
|
||||||
delete instance->database;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete instance->storage;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
Instance::BeginShutdownPartitions() noexcept
|
Instance::BeginShutdownPartitions() noexcept
|
||||||
{
|
{
|
||||||
@ -648,7 +635,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
instance->FinishShutdownUpdate();
|
instance->FinishShutdownUpdate();
|
||||||
instance->ShutdownDatabase();
|
|
||||||
|
|
||||||
#ifdef ENABLE_SQLITE
|
#ifdef ENABLE_SQLITE
|
||||||
sticker_global_finish();
|
sticker_global_finish();
|
||||||
|
Loading…
Reference in New Issue
Block a user