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
28a2d41b
Commit
28a2d41b
authored
7 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/DatabasePlugin: pass EventThread's EventLoop to create()
Allows database plugins to use the EventThread, e.g. for CURL integration.
parent
7e76656a
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
13 deletions
+29
-13
Main.cxx
src/Main.cxx
+3
-1
Configured.cxx
src/db/Configured.cxx
+4
-4
Configured.hxx
src/db/Configured.hxx
+1
-1
DatabaseGlue.cxx
src/db/DatabaseGlue.cxx
+3
-1
DatabaseGlue.hxx
src/db/DatabaseGlue.hxx
+1
-0
DatabasePlugin.hxx
src/db/DatabasePlugin.hxx
+3
-0
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+5
-2
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+1
-1
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+3
-1
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+4
-2
DumpDatabase.cxx
test/DumpDatabase.cxx
+1
-0
No files found.
src/Main.cxx
View file @
28a2d41b
...
@@ -193,7 +193,9 @@ static bool
...
@@ -193,7 +193,9 @@ static bool
glue_db_init_and_load
(
void
)
glue_db_init_and_load
(
void
)
{
{
instance
->
database
=
instance
->
database
=
CreateConfiguredDatabase
(
instance
->
event_loop
,
*
instance
);
CreateConfiguredDatabase
(
instance
->
event_loop
,
instance
->
io_thread
.
GetEventLoop
(),
*
instance
);
if
(
instance
->
database
==
nullptr
)
if
(
instance
->
database
==
nullptr
)
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/db/Configured.cxx
View file @
28a2d41b
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "util/RuntimeError.hxx"
#include "util/RuntimeError.hxx"
Database
*
Database
*
CreateConfiguredDatabase
(
EventLoop
&
main_event_loop
,
CreateConfiguredDatabase
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
)
DatabaseListener
&
listener
)
{
{
const
auto
*
param
=
config_get_block
(
ConfigBlockOption
::
DATABASE
);
const
auto
*
param
=
config_get_block
(
ConfigBlockOption
::
DATABASE
);
...
@@ -39,12 +39,12 @@ CreateConfiguredDatabase(EventLoop &main_event_loop,
...
@@ -39,12 +39,12 @@ CreateConfiguredDatabase(EventLoop &main_event_loop,
param
->
line
,
path
->
line
);
param
->
line
,
path
->
line
);
if
(
param
!=
nullptr
)
if
(
param
!=
nullptr
)
return
DatabaseGlobalInit
(
main_event_loop
,
return
DatabaseGlobalInit
(
main_event_loop
,
io_event_loop
,
listener
,
*
param
);
listener
,
*
param
);
else
if
(
path
!=
nullptr
)
{
else
if
(
path
!=
nullptr
)
{
ConfigBlock
block
(
path
->
line
);
ConfigBlock
block
(
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
(),
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
(),
path
->
line
);
return
DatabaseGlobalInit
(
main_event_loop
,
return
DatabaseGlobalInit
(
main_event_loop
,
io_event_loop
,
listener
,
block
);
listener
,
block
);
}
else
{
}
else
{
/* if there is no override, use the cache directory */
/* if there is no override, use the cache directory */
...
@@ -61,7 +61,7 @@ CreateConfiguredDatabase(EventLoop &main_event_loop,
...
@@ -61,7 +61,7 @@ CreateConfiguredDatabase(EventLoop &main_event_loop,
ConfigBlock
block
;
ConfigBlock
block
;
block
.
AddBlockParam
(
"path"
,
db_file_utf8
.
c_str
(),
-
1
);
block
.
AddBlockParam
(
"path"
,
db_file_utf8
.
c_str
(),
-
1
);
return
DatabaseGlobalInit
(
main_event_loop
,
return
DatabaseGlobalInit
(
main_event_loop
,
io_event_loop
,
listener
,
block
);
listener
,
block
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/db/Configured.hxx
View file @
28a2d41b
...
@@ -34,7 +34,7 @@ class Database;
...
@@ -34,7 +34,7 @@ class Database;
* Throws #std::runtime_error on error.
* Throws #std::runtime_error on error.
*/
*/
Database
*
Database
*
CreateConfiguredDatabase
(
EventLoop
&
main_event_loop
,
CreateConfiguredDatabase
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
);
DatabaseListener
&
listener
);
#endif
#endif
This diff is collapsed.
Click to expand it.
src/db/DatabaseGlue.cxx
View file @
28a2d41b
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
Database
*
Database
*
DatabaseGlobalInit
(
EventLoop
&
main_event_loop
,
DatabaseGlobalInit
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
)
const
ConfigBlock
&
block
)
{
{
...
@@ -39,7 +40,8 @@ DatabaseGlobalInit(EventLoop &main_event_loop,
...
@@ -39,7 +40,8 @@ DatabaseGlobalInit(EventLoop &main_event_loop,
plugin_name
);
plugin_name
);
try
{
try
{
return
plugin
->
create
(
main_event_loop
,
listener
,
block
);
return
plugin
->
create
(
main_event_loop
,
io_event_loop
,
listener
,
block
);
}
catch
(...)
{
}
catch
(...)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to initialize database plugin '%s'"
,
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to initialize database plugin '%s'"
,
plugin_name
));
plugin_name
));
...
...
This diff is collapsed.
Click to expand it.
src/db/DatabaseGlue.hxx
View file @
28a2d41b
...
@@ -36,6 +36,7 @@ class Database;
...
@@ -36,6 +36,7 @@ class Database;
*/
*/
Database
*
Database
*
DatabaseGlobalInit
(
EventLoop
&
main_event_loop
,
DatabaseGlobalInit
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
...
...
This diff is collapsed.
Click to expand it.
src/db/DatabasePlugin.hxx
View file @
28a2d41b
...
@@ -49,8 +49,11 @@ struct DatabasePlugin {
...
@@ -49,8 +49,11 @@ struct DatabasePlugin {
*
*
* @param main_event_loop the #EventLoop running in the same
* @param main_event_loop the #EventLoop running in the same
* thread which invokes #Database methods
* thread which invokes #Database methods
* @param io_event_loop the #EventLoop running on the
* #EventThread, i.e. the one used for background I/O
*/
*/
Database
*
(
*
create
)(
EventLoop
&
main_event_loop
,
Database
*
(
*
create
)(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
28a2d41b
...
@@ -107,7 +107,9 @@ public:
...
@@ -107,7 +107,9 @@ public:
ProxyDatabase
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
ProxyDatabase
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
static
Database
*
Create
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
void
Open
()
override
;
void
Open
()
override
;
...
@@ -345,7 +347,8 @@ ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
...
@@ -345,7 +347,8 @@ ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
}
}
Database
*
Database
*
ProxyDatabase
::
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
ProxyDatabase
::
Create
(
EventLoop
&
loop
,
EventLoop
&
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
)
const
ConfigBlock
&
block
)
{
{
return
new
ProxyDatabase
(
loop
,
listener
,
block
);
return
new
ProxyDatabase
(
loop
,
listener
,
block
);
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
28a2d41b
...
@@ -83,7 +83,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
...
@@ -83,7 +83,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
}
}
Database
*
Database
*
SimpleDatabase
::
Create
(
gcc_unused
EventLoop
&
loop
,
SimpleDatabase
::
Create
(
EventLoop
&
,
EventLoop
&
,
gcc_unused
DatabaseListener
&
listener
,
gcc_unused
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
)
const
ConfigBlock
&
block
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
28a2d41b
...
@@ -72,7 +72,9 @@ class SimpleDatabase : public Database {
...
@@ -72,7 +72,9 @@ class SimpleDatabase : public Database {
SimpleDatabase
(
AllocatedPath
&&
_path
,
bool
_compress
);
SimpleDatabase
(
AllocatedPath
&&
_path
,
bool
_compress
);
public
:
public
:
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
static
Database
*
Create
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
gcc_pure
gcc_pure
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
28a2d41b
...
@@ -75,7 +75,9 @@ class UpnpDatabase : public Database {
...
@@ -75,7 +75,9 @@ class UpnpDatabase : public Database {
public
:
public
:
UpnpDatabase
()
:
Database
(
upnp_db_plugin
)
{}
UpnpDatabase
()
:
Database
(
upnp_db_plugin
)
{}
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
static
Database
*
Create
(
EventLoop
&
main_event_loop
,
EventLoop
&
io_event_loop
,
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
void
Open
()
override
;
void
Open
()
override
;
...
@@ -138,7 +140,7 @@ private:
...
@@ -138,7 +140,7 @@ private:
};
};
Database
*
Database
*
UpnpDatabase
::
Create
(
gcc_unused
EventLoop
&
loop
,
UpnpDatabase
::
Create
(
EventLoop
&
,
EventLoop
&
,
gcc_unused
DatabaseListener
&
listener
,
gcc_unused
DatabaseListener
&
listener
,
const
ConfigBlock
&
)
const
ConfigBlock
&
)
{
{
...
...
This diff is collapsed.
Click to expand it.
test/DumpDatabase.cxx
View file @
28a2d41b
...
@@ -138,6 +138,7 @@ try {
...
@@ -138,6 +138,7 @@ try {
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
(),
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
(),
path
->
line
);
Database
*
db
=
plugin
->
create
(
init
.
GetEventLoop
(),
Database
*
db
=
plugin
->
create
(
init
.
GetEventLoop
(),
init
.
GetEventLoop
(),
database_listener
,
block
);
database_listener
,
block
);
AtScopeExit
(
db
)
{
delete
db
;
};
AtScopeExit
(
db
)
{
delete
db
;
};
...
...
This diff is collapsed.
Click to expand it.
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