summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--src/Main.cxx2
-rw-r--r--src/command/StorageCommands.cxx6
-rw-r--r--src/storage/Configured.cxx9
-rw-r--r--src/storage/Configured.hxx3
-rw-r--r--src/storage/Registry.cxx4
-rw-r--r--src/storage/Registry.hxx3
-rw-r--r--src/storage/StoragePlugin.hxx4
-rw-r--r--src/storage/plugins/NfsStorage.cxx3
-rw-r--r--src/storage/plugins/SmbclientStorage.cxx3
-rw-r--r--test/run_storage.cxx5
11 files changed, 31 insertions, 15 deletions
diff --git a/Makefile.am b/Makefile.am
index 23a43d19b..213fda2e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1589,11 +1589,15 @@ endif
test_run_storage_LDADD = \
$(STORAGE_LIBS) \
$(FS_LIBS) \
+ libevent.a \
+ libthread.a \
libsystem.a \
libutil.a \
$(GLIB_LIBS)
test_run_storage_SOURCES = \
src/Log.cxx src/LogBackend.cxx \
+ src/IOThread.cxx \
+ test/ScopeIOThread.hxx \
test/run_storage.cxx
endif
diff --git a/src/Main.cxx b/src/Main.cxx
index e41489688..417e055d6 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -166,7 +166,7 @@ glue_mapper_init(Error &error)
static bool
InitStorage(Error &error)
{
- Storage *storage = CreateConfiguredStorage(error);
+ Storage *storage = CreateConfiguredStorage(io_thread_get(), error);
if (storage == nullptr)
return !error.IsDefined();
diff --git a/src/command/StorageCommands.cxx b/src/command/StorageCommands.cxx
index aeec73e1c..ee51c573e 100644
--- a/src/command/StorageCommands.cxx
+++ b/src/command/StorageCommands.cxx
@@ -35,6 +35,7 @@
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
#include "db/update/Service.hxx"
#include "TimePrint.hxx"
+#include "IOThread.hxx"
#include "Idle.hxx"
#include <inttypes.h> /* for PRIu64 */
@@ -121,7 +122,7 @@ CommandResult
handle_listfiles_storage(Client &client, const char *uri)
{
Error error;
- Storage *storage = CreateStorageURI(uri, error);
+ Storage *storage = CreateStorageURI(io_thread_get(), uri, error);
if (storage == nullptr) {
if (error.IsDefined())
return print_error(client, error);
@@ -217,7 +218,8 @@ handle_mount(Client &client, gcc_unused unsigned argc, char *argv[])
}
Error error;
- Storage *storage = CreateStorageURI(remote_uri, error);
+ Storage *storage = CreateStorageURI(io_thread_get(), remote_uri,
+ error);
if (storage == nullptr) {
if (error.IsDefined())
return print_error(client, error);
diff --git a/src/storage/Configured.cxx b/src/storage/Configured.cxx
index 800a18ba0..41541673b 100644
--- a/src/storage/Configured.cxx
+++ b/src/storage/Configured.cxx
@@ -31,9 +31,10 @@
#include <assert.h>
static Storage *
-CreateConfiguredStorageUri(const char *uri, Error &error)
+CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri,
+ Error &error)
{
- Storage *storage = CreateStorageURI(uri, error);
+ Storage *storage = CreateStorageURI(event_loop, uri, error);
if (storage == nullptr && !error.IsDefined())
error.Format(config_domain,
"Unrecognized storage URI: %s", uri);
@@ -63,13 +64,13 @@ CreateConfiguredStorageLocal(Error &error)
}
Storage *
-CreateConfiguredStorage(Error &error)
+CreateConfiguredStorage(EventLoop &event_loop, Error &error)
{
assert(!error.IsDefined());
auto uri = config_get_string(CONF_MUSIC_DIR, nullptr);
if (uri != nullptr && uri_has_scheme(uri))
- return CreateConfiguredStorageUri(uri, error);
+ return CreateConfiguredStorageUri(event_loop, uri, error);
return CreateConfiguredStorageLocal(error);
}
diff --git a/src/storage/Configured.hxx b/src/storage/Configured.hxx
index d78857a26..828a192c3 100644
--- a/src/storage/Configured.hxx
+++ b/src/storage/Configured.hxx
@@ -25,6 +25,7 @@
class Error;
class Storage;
+class EventLoop;
/**
* Read storage configuration settings and create a #Storage instance
@@ -32,7 +33,7 @@ class Storage;
* (no #Error set in that case).
*/
Storage *
-CreateConfiguredStorage(Error &error);
+CreateConfiguredStorage(EventLoop &event_loop, Error &error);
/**
* Returns true if there is configuration for a #Storage instance.
diff --git a/src/storage/Registry.cxx b/src/storage/Registry.cxx
index b3fdd1642..d8e273fd5 100644
--- a/src/storage/Registry.cxx
+++ b/src/storage/Registry.cxx
@@ -52,7 +52,7 @@ GetStoragePluginByName(const char *name)
}
Storage *
-CreateStorageURI(const char *uri, Error &error)
+CreateStorageURI(EventLoop &event_loop, const char *uri, Error &error)
{
assert(!error.IsDefined());
@@ -62,7 +62,7 @@ CreateStorageURI(const char *uri, Error &error)
if (plugin.create_uri == nullptr)
continue;
- Storage *storage = plugin.create_uri(uri, error);
+ Storage *storage = plugin.create_uri(event_loop, uri, error);
if (storage != nullptr || error.IsDefined())
return storage;
}
diff --git a/src/storage/Registry.hxx b/src/storage/Registry.hxx
index 9696b3de1..cb3a78f11 100644
--- a/src/storage/Registry.hxx
+++ b/src/storage/Registry.hxx
@@ -26,6 +26,7 @@
struct StoragePlugin;
class Storage;
class Error;
+class EventLoop;
/**
* nullptr terminated list of all storage plugins which were enabled at
@@ -39,6 +40,6 @@ GetStoragePluginByName(const char *name);
gcc_nonnull_all gcc_malloc
Storage *
-CreateStorageURI(const char *uri, Error &error);
+CreateStorageURI(EventLoop &event_loop, const char *uri, Error &error);
#endif
diff --git a/src/storage/StoragePlugin.hxx b/src/storage/StoragePlugin.hxx
index d91caf24b..15f431105 100644
--- a/src/storage/StoragePlugin.hxx
+++ b/src/storage/StoragePlugin.hxx
@@ -24,11 +24,13 @@
class Error;
class Storage;
+class EventLoop;
struct StoragePlugin {
const char *name;
- Storage *(*create_uri)(const char *uri, Error &error);
+ Storage *(*create_uri)(EventLoop &event_loop, const char *uri,
+ Error &error);
};
#endif
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx
index 273d0aacc..e28e41a67 100644
--- a/src/storage/plugins/NfsStorage.cxx
+++ b/src/storage/plugins/NfsStorage.cxx
@@ -203,7 +203,8 @@ NfsStorage::OpenDirectory(const char *uri_utf8, Error &error)
}
static Storage *
-CreateNfsStorageURI(const char *base, Error &error)
+CreateNfsStorageURI(gcc_unused EventLoop &event_loop, const char *base,
+ Error &error)
{
if (memcmp(base, "nfs://", 6) != 0)
return nullptr;
diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx
index 6eda05073..70a6e16bb 100644
--- a/src/storage/plugins/SmbclientStorage.cxx
+++ b/src/storage/plugins/SmbclientStorage.cxx
@@ -180,7 +180,8 @@ SmbclientDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info,
}
static Storage *
-CreateSmbclientStorageURI(const char *base, Error &error)
+CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base,
+ Error &error)
{
if (memcmp(base, "smb://", 6) != 0)
return nullptr;
diff --git a/test/run_storage.cxx b/test/run_storage.cxx
index 45575b9e0..9fc6e6e76 100644
--- a/test/run_storage.cxx
+++ b/test/run_storage.cxx
@@ -18,6 +18,7 @@
*/
#include "config.h"
+#include "ScopeIOThread.hxx"
#include "storage/Registry.hxx"
#include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx"
@@ -38,7 +39,7 @@ static Storage *
MakeStorage(const char *uri)
{
Error error;
- Storage *storage = CreateStorageURI(uri, error);
+ Storage *storage = CreateStorageURI(io_thread_get(), uri, error);
if (storage == nullptr) {
fprintf(stderr, "%s\n", error.GetMessage());
exit(EXIT_FAILURE);
@@ -112,6 +113,8 @@ main(int argc, char **argv)
const char *const command = argv[1];
const char *const storage_uri = argv[2];
+ const ScopeIOThread io_thread;
+
if (strcmp(command, "ls") == 0) {
if (argc != 4) {
fprintf(stderr, "Usage: run_storage ls URI PATH\n");