You need to sign in or sign up before continuing.
Commit f82e1453 authored by Max Kellermann's avatar Max Kellermann

input/smbclient: use std::lock_guard

parent a2b77c88
...@@ -125,9 +125,13 @@ input_smbclient_open(const char *uri, ...@@ -125,9 +125,13 @@ input_smbclient_open(const char *uri,
size_t size_t
SmbclientInputStream::Read(void *ptr, size_t read_size) SmbclientInputStream::Read(void *ptr, size_t read_size)
{ {
smbclient_mutex.lock(); ssize_t nbytes;
ssize_t nbytes = smbc_read(fd, ptr, read_size);
smbclient_mutex.unlock(); {
const std::lock_guard<Mutex> lock(smbclient_mutex);
nbytes = smbc_read(fd, ptr, read_size);
}
if (nbytes < 0) if (nbytes < 0)
throw MakeErrno("smbc_read() failed"); throw MakeErrno("smbc_read() failed");
...@@ -138,9 +142,13 @@ SmbclientInputStream::Read(void *ptr, size_t read_size) ...@@ -138,9 +142,13 @@ SmbclientInputStream::Read(void *ptr, size_t read_size)
void void
SmbclientInputStream::Seek(offset_type new_offset) SmbclientInputStream::Seek(offset_type new_offset)
{ {
smbclient_mutex.lock(); off_t result;
off_t result = smbc_lseek(fd, new_offset, SEEK_SET);
smbclient_mutex.unlock(); {
const std::lock_guard<Mutex> lock(smbclient_mutex);
result = smbc_lseek(fd, new_offset, SEEK_SET);
}
if (result < 0) if (result < 0)
throw MakeErrno("smbc_lseek() failed"); throw MakeErrno("smbc_lseek() failed");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment