diff options
author | Max Kellermann <max@musicpd.org> | 2017-11-13 17:12:21 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-11-13 17:13:10 +0100 |
commit | f82e1453e476bd6c9114e2adf4144eb643950b0e (patch) | |
tree | 4a02cd2a77131378cbf62d952f995528a46c60d3 /src | |
parent | a2b77c88136788e68824251ac33c0200f2c9cd17 (diff) |
input/smbclient: use std::lock_guard
Diffstat (limited to 'src')
-rw-r--r-- | src/input/plugins/SmbclientInputPlugin.cxx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx index 8e802a8e1..35bb5c5b8 100644 --- a/src/input/plugins/SmbclientInputPlugin.cxx +++ b/src/input/plugins/SmbclientInputPlugin.cxx @@ -125,9 +125,13 @@ input_smbclient_open(const char *uri, size_t SmbclientInputStream::Read(void *ptr, size_t read_size) { - smbclient_mutex.lock(); - ssize_t nbytes = smbc_read(fd, ptr, read_size); - smbclient_mutex.unlock(); + ssize_t nbytes; + + { + const std::lock_guard<Mutex> lock(smbclient_mutex); + nbytes = smbc_read(fd, ptr, read_size); + } + if (nbytes < 0) throw MakeErrno("smbc_read() failed"); @@ -138,9 +142,13 @@ SmbclientInputStream::Read(void *ptr, size_t read_size) void SmbclientInputStream::Seek(offset_type new_offset) { - smbclient_mutex.lock(); - off_t result = smbc_lseek(fd, new_offset, SEEK_SET); - smbclient_mutex.unlock(); + off_t result; + + { + const std::lock_guard<Mutex> lock(smbclient_mutex); + result = smbc_lseek(fd, new_offset, SEEK_SET); + } + if (result < 0) throw MakeErrno("smbc_lseek() failed"); |