Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
99c23cf1
Commit
99c23cf1
authored
Feb 15, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instance: eliminate ShutdownDatabase(), move code to destructor
Destruct automatically, even if leaving the scope due to exception being thrown.
parent
9aa75e73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
Instance.cxx
src/Instance.cxx
+13
-1
Instance.hxx
src/Instance.hxx
+0
-1
Main.cxx
src/Main.cxx
+0
-14
No files found.
src/Instance.cxx
View file @
99c23cf1
...
@@ -30,6 +30,8 @@
...
@@ -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()
...
@@ -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
...
...
src/Instance.hxx
View file @
99c23cf1
...
@@ -168,7 +168,6 @@ struct Instance final
...
@@ -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
;
...
...
src/Main.cxx
View file @
99c23cf1
...
@@ -360,19 +360,6 @@ Instance::FinishShutdownUpdate() noexcept
...
@@ -360,19 +360,6 @@ Instance::FinishShutdownUpdate() noexcept
}
}
inline
void
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
Instance
::
BeginShutdownPartitions
()
noexcept
{
{
for
(
auto
&
partition
:
partitions
)
{
for
(
auto
&
partition
:
partitions
)
{
...
@@ -648,7 +635,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment