input/smbclient: use std::lock_guard
This commit is contained in:
		@@ -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)
 | 
				
			|||||||
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");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user