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
52da387a
Commit
52da387a
authored
Jan 29, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main: move part of the shutdown code to Instance methods
parent
c1221c5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
21 deletions
+59
-21
Instance.hxx
src/Instance.hxx
+7
-0
Main.cxx
src/Main.cxx
+52
-21
No files found.
src/Instance.hxx
View file @
52da387a
...
...
@@ -114,6 +114,9 @@ struct Instance final
gcc_pure
Partition
*
FindPartition
(
const
char
*
name
)
noexcept
;
void
BeginShutdownPartitions
()
noexcept
;
void
FinishShutdownPartitions
()
noexcept
;
#ifdef ENABLE_DATABASE
/**
* Returns the global #Database instance. May return nullptr
...
...
@@ -132,6 +135,10 @@ struct Instance final
const
Database
&
GetDatabaseOrThrow
()
const
;
#endif
void
BeginShutdownUpdate
()
noexcept
;
void
FinishShutdownUpdate
()
noexcept
;
void
ShutdownDatabase
()
noexcept
;
private
:
#ifdef ENABLE_DATABASE
void
OnDatabaseModified
()
override
;
...
...
src/Main.cxx
View file @
52da387a
...
...
@@ -405,6 +405,53 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
}
}
inline
void
Instance
::
BeginShutdownUpdate
()
noexcept
{
#ifdef ENABLE_DATABASE
#ifdef ENABLE_INOTIFY
mpd_inotify_finish
();
#endif
if
(
update
!=
nullptr
)
update
->
CancelAllAsync
();
#endif
}
inline
void
Instance
::
FinishShutdownUpdate
()
noexcept
{
#ifdef ENABLE_DATABASE
delete
update
;
#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
Instance
::
BeginShutdownPartitions
()
noexcept
{
for
(
auto
&
partition
:
partitions
)
partition
.
pc
.
Kill
();
}
inline
void
Instance
::
FinishShutdownPartitions
()
noexcept
{
partitions
.
clear
();
}
void
Instance
::
OnIdle
(
unsigned
flags
)
{
...
...
@@ -643,22 +690,14 @@ try {
/* cleanup */
#ifdef ENABLE_DATABASE
#ifdef ENABLE_INOTIFY
mpd_inotify_finish
();
#endif
if
(
instance
->
update
!=
nullptr
)
instance
->
update
->
CancelAllAsync
();
#endif
instance
->
BeginShutdownUpdate
();
if
(
instance
->
state_file
!=
nullptr
)
{
instance
->
state_file
->
Write
();
delete
instance
->
state_file
;
}
for
(
auto
&
partition
:
instance
->
partitions
)
partition
.
pc
.
Kill
();
instance
->
BeginShutdownPartitions
();
ZeroconfDeinit
();
listen_global_finish
();
...
...
@@ -671,16 +710,8 @@ try {
}
#endif
#ifdef ENABLE_DATABASE
delete
instance
->
update
;
if
(
instance
->
database
!=
nullptr
)
{
instance
->
database
->
Close
();
delete
instance
->
database
;
}
delete
instance
->
storage
;
#endif
instance
->
FinishShutdownUpdate
();
instance
->
ShutdownDatabase
();
#ifdef ENABLE_SQLITE
sticker_global_finish
();
...
...
@@ -695,7 +726,7 @@ try {
DeinitFS
();
instance
->
partitions
.
clear
();
instance
->
FinishShutdownPartitions
();
command_finish
();
decoder_plugin_deinit_all
();
#ifdef ENABLE_ARCHIVE
...
...
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