summaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-07-20 17:32:40 +0200
committerMax Kellermann <max@musicpd.org>2020-07-20 22:01:10 +0200
commit697531a948bc8f21cd56c591bb5b5cd523cd30d1 (patch)
tree474a8db7b1034fdfc11f208136672eb36a24b9ed /src/storage
parentb04c6fbd7287fb7155a8a24852aa274b99dd1ac6 (diff)
lib/smbclient/Context: new wrapper for SMBCCTX
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/plugins/SmbclientStorage.cxx25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx
index c227978c4..f65c1efc1 100644
--- a/src/storage/plugins/SmbclientStorage.cxx
+++ b/src/storage/plugins/SmbclientStorage.cxx
@@ -22,6 +22,7 @@
#include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx"
#include "lib/smbclient/Init.hxx"
+#include "lib/smbclient/Context.hxx"
#include "lib/smbclient/Mutex.hxx"
#include "fs/Traits.hxx"
#include "thread/Mutex.hxx"
@@ -52,16 +53,11 @@ public:
class SmbclientStorage final : public Storage {
const std::string base;
- SMBCCTX *const ctx;
+ SmbclientContext ctx = SmbclientContext::New();
public:
- SmbclientStorage(const char *_base, SMBCCTX *_ctx)
- :base(_base), ctx(_ctx) {}
-
- ~SmbclientStorage() override {
- const std::lock_guard<Mutex> lock(smbclient_mutex);
- smbc_free_context(ctx, 1);
- }
+ explicit SmbclientStorage(const char *_base)
+ :base(_base) {}
/* virtual methods from class Storage */
StorageFileInfo GetInfo(std::string_view uri_utf8, bool follow) override;
@@ -184,18 +180,7 @@ CreateSmbclientStorageURI([[maybe_unused]] EventLoop &event_loop, const char *ba
SmbclientInit();
- const std::lock_guard<Mutex> protect(smbclient_mutex);
- SMBCCTX *ctx = smbc_new_context();
- if (ctx == nullptr)
- throw MakeErrno("smbc_new_context() failed");
-
- SMBCCTX *ctx2 = smbc_init_context(ctx);
- if (ctx2 == nullptr) {
- AtScopeExit(ctx) { smbc_free_context(ctx, 1); };
- throw MakeErrno("smbc_new_context() failed");
- }
-
- return std::make_unique<SmbclientStorage>(base, ctx2);
+ return std::make_unique<SmbclientStorage>(base);
}
const StoragePlugin smbclient_storage_plugin = {