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
135662d6
Commit
135662d6
authored
Sep 05, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/smbclient/Init: throw std::runtime_error on error
parent
a69c3c18
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
21 deletions
+18
-21
SmbclientInputPlugin.cxx
src/input/plugins/SmbclientInputPlugin.cxx
+7
-2
Init.cxx
src/lib/smbclient/Init.cxx
+5
-9
Init.hxx
src/lib/smbclient/Init.hxx
+4
-6
SmbclientNeighborPlugin.cxx
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+1
-2
SmbclientStorage.cxx
src/storage/plugins/SmbclientStorage.cxx
+1
-2
No files found.
src/input/plugins/SmbclientInputPlugin.cxx
View file @
135662d6
...
...
@@ -28,6 +28,8 @@
#include <libsmbclient.h>
#include <stdexcept>
class
SmbclientInputStream
final
:
public
InputStream
{
SMBCCTX
*
ctx
;
int
fd
;
...
...
@@ -66,10 +68,13 @@ public:
*/
static
InputPlugin
::
InitResult
input_smbclient_init
(
gcc_unused
const
ConfigBlock
&
block
,
Error
&
error
)
input_smbclient_init
(
gcc_unused
const
ConfigBlock
&
block
,
gcc_unused
Error
&
error
)
{
if
(
!
SmbclientInit
(
error
))
try
{
SmbclientInit
();
}
catch
(
const
std
::
runtime_error
&
e
)
{
return
InputPlugin
::
InitResult
::
UNAVAILABLE
;
}
// TODO: create one global SMBCCTX here?
...
...
src/lib/smbclient/Init.cxx
View file @
135662d6
...
...
@@ -21,7 +21,7 @@
#include "Init.hxx"
#include "Mutex.hxx"
#include "thread/Mutex.hxx"
#include "
util
/Error.hxx"
#include "
system
/Error.hxx"
#include <libsmbclient.h>
...
...
@@ -40,16 +40,12 @@ mpd_smbc_get_auth_data(gcc_unused const char *srv,
strcpy
(
pw
,
""
);
}
bool
SmbclientInit
(
Error
&
error
)
void
SmbclientInit
()
{
const
ScopeLock
protect
(
smbclient_mutex
);
constexpr
int
debug
=
0
;
if
(
smbc_init
(
mpd_smbc_get_auth_data
,
debug
)
<
0
)
{
error
.
SetErrno
(
"smbc_init() failed"
);
return
false
;
}
return
true
;
if
(
smbc_init
(
mpd_smbc_get_auth_data
,
debug
)
<
0
)
throw
MakeErrno
(
"smbc_init() failed"
);
}
src/lib/smbclient/Init.hxx
View file @
135662d6
...
...
@@ -20,14 +20,12 @@
#ifndef MPD_SMBCLIENT_INIT_HXX
#define MPD_SMBCLIENT_INIT_HXX
#include "check.h"
class
Error
;
/**
* Initialize libsmbclient.
*
* Throws std::runtime_error on error.
*/
bool
SmbclientInit
(
Error
&
error
);
void
SmbclientInit
();
#endif
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
135662d6
...
...
@@ -273,8 +273,7 @@ smbclient_neighbor_create(gcc_unused EventLoop &loop,
gcc_unused
const
ConfigBlock
&
block
,
gcc_unused
Error
&
error
)
{
if
(
!
SmbclientInit
(
error
))
return
nullptr
;
SmbclientInit
();
return
new
SmbclientNeighborExplorer
(
listener
);
}
...
...
src/storage/plugins/SmbclientStorage.cxx
View file @
135662d6
...
...
@@ -189,8 +189,7 @@ CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base,
if
(
memcmp
(
base
,
"smb://"
,
6
)
!=
0
)
return
nullptr
;
if
(
!
SmbclientInit
(
error
))
return
nullptr
;
SmbclientInit
();
const
ScopeLock
protect
(
smbclient_mutex
);
SMBCCTX
*
ctx
=
smbc_new_context
();
...
...
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