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
3d2558bd
Commit
3d2558bd
authored
Oct 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StoragePlugin: pass EventLoop to constructor
parent
1aac0b10
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
31 additions
and
15 deletions
+31
-15
Makefile.am
Makefile.am
+4
-0
Main.cxx
src/Main.cxx
+1
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+4
-2
Configured.cxx
src/storage/Configured.cxx
+5
-4
Configured.hxx
src/storage/Configured.hxx
+2
-1
Registry.cxx
src/storage/Registry.cxx
+2
-2
Registry.hxx
src/storage/Registry.hxx
+2
-1
StoragePlugin.hxx
src/storage/StoragePlugin.hxx
+3
-1
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+2
-1
SmbclientStorage.cxx
src/storage/plugins/SmbclientStorage.cxx
+2
-1
run_storage.cxx
test/run_storage.cxx
+4
-1
No files found.
Makefile.am
View file @
3d2558bd
...
...
@@ -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
...
...
src/Main.cxx
View file @
3d2558bd
...
...
@@ -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
();
...
...
src/command/StorageCommands.cxx
View file @
3d2558bd
...
...
@@ -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
);
...
...
src/storage/Configured.cxx
View file @
3d2558bd
...
...
@@ -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
(
E
ventLoop
&
event_loop
,
E
rror
&
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
);
}
...
...
src/storage/Configured.hxx
View file @
3d2558bd
...
...
@@ -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
(
E
ventLoop
&
event_loop
,
E
rror
&
error
);
/**
* Returns true if there is configuration for a #Storage instance.
...
...
src/storage/Registry.cxx
View file @
3d2558bd
...
...
@@ -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
;
}
...
...
src/storage/Registry.hxx
View file @
3d2558bd
...
...
@@ -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
src/storage/StoragePlugin.hxx
View file @
3d2558bd
...
...
@@ -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
src/storage/plugins/NfsStorage.cxx
View file @
3d2558bd
...
...
@@ -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
;
...
...
src/storage/plugins/SmbclientStorage.cxx
View file @
3d2558bd
...
...
@@ -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
;
...
...
test/run_storage.cxx
View file @
3d2558bd
...
...
@@ -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
"
);
...
...
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