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:
@@ -87,14 +87,24 @@ input_file_open(gcc_unused const char *filename,
|
||||
void
|
||||
FileInputStream::Seek(offset_type new_offset)
|
||||
{
|
||||
reader.Seek((off_t)new_offset);
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
reader.Seek((off_t)new_offset);
|
||||
}
|
||||
|
||||
offset = new_offset;
|
||||
}
|
||||
|
||||
size_t
|
||||
FileInputStream::Read(void *ptr, size_t read_size)
|
||||
{
|
||||
size_t nbytes = reader.Read(ptr, read_size);
|
||||
size_t nbytes;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
nbytes = reader.Read(ptr, read_size);
|
||||
}
|
||||
|
||||
offset += nbytes;
|
||||
return nbytes;
|
||||
}
|
||||
|
Reference in New Issue
Block a user