diff --git a/src/db/Configured.cxx b/src/db/Configured.cxx index 69aa98529..249a6e26e 100644 --- a/src/db/Configured.cxx +++ b/src/db/Configured.cxx @@ -28,7 +28,8 @@ #include "util/RuntimeError.hxx" Database * -CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener) +CreateConfiguredDatabase(EventLoop &main_event_loop, + DatabaseListener &listener) { const auto *param = config_get_block(ConfigBlockOption::DATABASE); const auto *path = config_get_param(ConfigOption::DB_FILE); @@ -38,11 +39,13 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener) param->line, path->line); if (param != nullptr) - return DatabaseGlobalInit(loop, listener, *param); + return DatabaseGlobalInit(main_event_loop, + listener, *param); else if (path != nullptr) { ConfigBlock block(path->line); block.AddBlockParam("path", path->value.c_str(), path->line); - return DatabaseGlobalInit(loop, listener, block); + return DatabaseGlobalInit(main_event_loop, + listener, block); } else { /* if there is no override, use the cache directory */ @@ -58,6 +61,7 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener) ConfigBlock block; block.AddBlockParam("path", db_file_utf8.c_str(), -1); - return DatabaseGlobalInit(loop, listener, block); + return DatabaseGlobalInit(main_event_loop, + listener, block); } } diff --git a/src/db/Configured.hxx b/src/db/Configured.hxx index 31f971d70..e2ba63ecc 100644 --- a/src/db/Configured.hxx +++ b/src/db/Configured.hxx @@ -34,6 +34,7 @@ class Database; * Throws #std::runtime_error on error. */ Database * -CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener); +CreateConfiguredDatabase(EventLoop &main_event_loop, + DatabaseListener &listener); #endif diff --git a/src/db/DatabaseGlue.cxx b/src/db/DatabaseGlue.cxx index 401162114..c5cd02977 100644 --- a/src/db/DatabaseGlue.cxx +++ b/src/db/DatabaseGlue.cxx @@ -26,7 +26,8 @@ #include "DatabasePlugin.hxx" Database * -DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener, +DatabaseGlobalInit(EventLoop &main_event_loop, + DatabaseListener &listener, const ConfigBlock &block) { const char *plugin_name = @@ -38,7 +39,7 @@ DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener, plugin_name); try { - return plugin->create(loop, listener, block); + return plugin->create(main_event_loop, listener, block); } catch (...) { std::throw_with_nested(FormatRuntimeError("Failed to initialize database plugin '%s'", plugin_name)); diff --git a/src/db/DatabaseGlue.hxx b/src/db/DatabaseGlue.hxx index 905b6c345..43b8e2a8f 100644 --- a/src/db/DatabaseGlue.hxx +++ b/src/db/DatabaseGlue.hxx @@ -35,7 +35,8 @@ class Database; * @param block the database configuration block */ Database * -DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener, +DatabaseGlobalInit(EventLoop &main_event_loop, + DatabaseListener &listener, const ConfigBlock &block); #endif diff --git a/src/db/DatabasePlugin.hxx b/src/db/DatabasePlugin.hxx index 49df3222c..db486a0cb 100644 --- a/src/db/DatabasePlugin.hxx +++ b/src/db/DatabasePlugin.hxx @@ -46,8 +46,12 @@ struct DatabasePlugin { * Allocates and configures a database. * * Throws #std::runtime_error on error. + * + * @param main_event_loop the #EventLoop running in the same + * thread which invokes #Database methods */ - Database *(*create)(EventLoop &loop, DatabaseListener &listener, + Database *(*create)(EventLoop &main_event_loop, + DatabaseListener &listener, const ConfigBlock &block); constexpr bool RequireStorage() const {