input/{cdio,ffmpeg,file,smbclient}: unlock the mutex during blocking I/O
InputStream::Read() and InputStream::Seek() are called with the mutex locked. That means the implementation must not block, or unlock the mutex before calling into blocking code. Previously, a slow CD drive could stall the whole MPD process, including the main thread, due to this problem. Closes #149
This commit is contained in:
@@ -128,6 +128,7 @@ SmbclientInputStream::Read(void *ptr, size_t read_size)
|
||||
ssize_t nbytes;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
const std::lock_guard<Mutex> lock(smbclient_mutex);
|
||||
nbytes = smbc_read(fd, ptr, read_size);
|
||||
}
|
||||
@@ -145,6 +146,7 @@ SmbclientInputStream::Seek(offset_type new_offset)
|
||||
off_t result;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
const std::lock_guard<Mutex> lock(smbclient_mutex);
|
||||
result = smbc_lseek(fd, new_offset, SEEK_SET);
|
||||
}
|
||||
|
Reference in New Issue
Block a user