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:
Max Kellermann
2017-11-13 17:08:00 +01:00
parent f82e1453e4
commit 31ab78ae8e
5 changed files with 35 additions and 5 deletions

View File

@@ -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);
}