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
5e081de1
Commit
5e081de1
authored
Feb 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOThread: move EventThread instance into struct Instance
Eliminate global variables.
parent
d1456ae0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
29 deletions
+20
-29
Makefile.am
Makefile.am
+0
-1
IOThread.cxx
src/IOThread.cxx
+0
-8
IOThread.hxx
src/IOThread.hxx
+0
-4
Instance.hxx
src/Instance.hxx
+3
-0
Main.cxx
src/Main.cxx
+9
-10
OtherCommands.cxx
src/command/OtherCommands.cxx
+2
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+5
-4
StorageCommands.hxx
src/command/StorageCommands.hxx
+1
-1
No files found.
Makefile.am
View file @
5e081de1
...
...
@@ -129,7 +129,6 @@ libmpd_a_SOURCES = \
src/Log.cxx src/Log.hxx src/LogV.hxx
\
src/LogLevel.hxx
\
src/ls.cxx src/ls.hxx
\
src/IOThread.cxx src/IOThread.hxx
\
src/Instance.cxx src/Instance.hxx
\
src/win32/Win32Main.cxx
\
src/MixRampInfo.hxx
\
...
...
src/IOThread.cxx
View file @
5e081de1
...
...
@@ -51,11 +51,3 @@ io_thread_deinit(void)
delete
io_thread
;
io_thread
=
nullptr
;
}
EventLoop
&
io_thread_get
()
{
assert
(
io_thread
!=
nullptr
);
return
io_thread
->
GetEventLoop
();
}
src/IOThread.hxx
View file @
5e081de1
...
...
@@ -33,8 +33,4 @@ io_thread_start();
void
io_thread_deinit
();
gcc_const
EventLoop
&
io_thread_get
();
#endif
src/Instance.hxx
View file @
5e081de1
...
...
@@ -22,6 +22,7 @@
#include "check.h"
#include "event/Loop.hxx"
#include "event/Thread.hxx"
#include "event/MaskMonitor.hxx"
#include "Compiler.h"
...
...
@@ -64,6 +65,8 @@ struct Instance final
public
NeighborListener
#endif
{
EventThread
io_thread
;
MaskMonitor
idle_monitor
;
#ifdef ENABLE_NEIGHBOR_PLUGINS
...
...
src/Main.cxx
View file @
5e081de1
...
...
@@ -39,7 +39,6 @@
#include "LogInit.hxx"
#include "input/Init.hxx"
#include "event/Loop.hxx"
#include "IOThread.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Config.hxx"
#include "playlist/PlaylistRegistry.hxx"
...
...
@@ -161,9 +160,9 @@ glue_mapper_init()
#ifdef ENABLE_DATABASE
static
void
InitStorage
()
InitStorage
(
EventLoop
&
event_loop
)
{
Storage
*
storage
=
CreateConfiguredStorage
(
io_thread_get
()
);
Storage
*
storage
=
CreateConfiguredStorage
(
event_loop
);
if
(
storage
==
nullptr
)
return
;
...
...
@@ -186,7 +185,7 @@ glue_db_init_and_load(void)
return
true
;
if
(
instance
->
database
->
GetPlugin
().
flags
&
DatabasePlugin
::
FLAG_REQUIRE_STORAGE
)
{
InitStorage
();
InitStorage
(
instance
->
io_thread
.
GetEventLoop
()
);
if
(
instance
->
storage
==
nullptr
)
{
delete
instance
->
database
;
...
...
@@ -421,7 +420,6 @@ try {
IcuInit
();
winsock_init
();
io_thread_init
();
config_global_init
();
#ifdef ANDROID
...
...
@@ -453,7 +451,8 @@ try {
#ifdef ENABLE_NEIGHBOR_PLUGINS
instance
->
neighbors
=
new
NeighborGlue
();
instance
->
neighbors
->
Init
(
io_thread_get
(),
*
instance
);
instance
->
neighbors
->
Init
(
instance
->
io_thread
.
GetEventLoop
(),
*
instance
);
if
(
instance
->
neighbors
->
IsEmpty
())
{
delete
instance
->
neighbors
;
...
...
@@ -519,13 +518,13 @@ try {
command_init
();
instance
->
partition
->
outputs
.
Configure
(
i
o_thread_get
(),
instance
->
partition
->
outputs
.
Configure
(
i
nstance
->
io_thread
.
GetEventLoop
(),
config
.
replay_gain
,
instance
->
partition
->
pc
);
instance
->
partition
->
UpdateEffectiveReplayGainMode
();
client_manager_init
();
input_stream_global_init
(
i
o_thread_get
());
input_stream_global_init
(
i
nstance
->
io_thread
.
GetEventLoop
());
playlist_list_global_init
();
#ifdef ENABLE_DAEMON
...
...
@@ -538,7 +537,7 @@ try {
SignalHandlersInit
(
instance
->
event_loop
);
#endif
i
o_thread_s
tart
();
i
nstance
->
io_thread
.
S
tart
();
#ifdef ENABLE_NEIGHBOR_PLUGINS
if
(
instance
->
neighbors
!=
nullptr
)
...
...
@@ -660,7 +659,7 @@ try {
archive_plugin_deinit_all
();
#endif
config_global_finish
();
i
o_thread_deinit
();
i
nstance
->
io_thread
.
Stop
();
#ifndef ANDROID
SignalHandlersFinish
();
#endif
...
...
src/command/OtherCommands.cxx
View file @
5e081de1
...
...
@@ -117,7 +117,8 @@ handle_listfiles(Client &client, Request args, Response &r)
case
LocatedUri
:
:
Type
::
ABSOLUTE
:
#ifdef ENABLE_DATABASE
/* use storage plugin to list remote directory */
return
handle_listfiles_storage
(
r
,
located_uri
.
canonical_uri
);
return
handle_listfiles_storage
(
client
,
r
,
located_uri
.
canonical_uri
);
#else
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
...
...
src/command/StorageCommands.cxx
View file @
5e081de1
...
...
@@ -36,7 +36,6 @@
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
#include "db/update/Service.hxx"
#include "TimePrint.hxx"
#include "IOThread.hxx"
#include "Idle.hxx"
#include <memory>
...
...
@@ -107,9 +106,10 @@ handle_listfiles_storage(Response &r, Storage &storage, const char *uri)
}
CommandResult
handle_listfiles_storage
(
Response
&
r
,
const
char
*
uri
)
handle_listfiles_storage
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
)
{
std
::
unique_ptr
<
Storage
>
storage
(
CreateStorageURI
(
io_thread_get
(),
uri
));
auto
&
event_loop
=
client
.
partition
.
instance
.
io_thread
.
GetEventLoop
();
std
::
unique_ptr
<
Storage
>
storage
(
CreateStorageURI
(
event_loop
,
uri
));
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
return
CommandResult
::
ERROR
;
...
...
@@ -195,7 +195,8 @@ handle_mount(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
}
Storage
*
storage
=
CreateStorageURI
(
io_thread_get
(),
remote_uri
);
auto
&
event_loop
=
client
.
partition
.
instance
.
io_thread
.
GetEventLoop
();
Storage
*
storage
=
CreateStorageURI
(
event_loop
,
remote_uri
);
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
return
CommandResult
::
ERROR
;
...
...
src/command/StorageCommands.hxx
View file @
5e081de1
...
...
@@ -31,7 +31,7 @@ CommandResult
handle_listfiles_storage
(
Response
&
r
,
Storage
&
storage
,
const
char
*
uri
);
CommandResult
handle_listfiles_storage
(
Response
&
r
,
const
char
*
uri
);
handle_listfiles_storage
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
);
CommandResult
handle_listmounts
(
Client
&
client
,
Request
request
,
Response
&
response
);
...
...
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