diff options
author | Max Kellermann <max@musicpd.org> | 2017-12-22 16:02:23 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-12-22 16:02:23 +0100 |
commit | 4b18460bc6d69332c8d4da64bf6fcaceadbb4864 (patch) | |
tree | 79f2db6701868733afbf39cdbe8f4b8520857985 /src | |
parent | 412c0a965cd3e7eba8f1649ada4da802cddccfda (diff) |
archive/bz2: unlock the archive mutex and lock the file mutex
Fixes deadlock because FileInputStream::Read() unlocks the mutex
(which was not locked) and then locks it, keeping it locked. This can
result in a deadlock. This happens because the archive and the file
mutex are different.
Diffstat (limited to 'src')
-rw-r--r-- | src/archive/plugins/Bzip2ArchivePlugin.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx index 3dc0b51c3..04597e2a2 100644 --- a/src/archive/plugins/Bzip2ArchivePlugin.cxx +++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx @@ -162,7 +162,7 @@ Bzip2InputStream::FillBuffer() if (bzstream.avail_in > 0) return true; - size_t count = archive->istream->Read(buffer, sizeof(buffer)); + size_t count = archive->istream->LockRead(buffer, sizeof(buffer)); if (count == 0) return false; @@ -174,6 +174,8 @@ Bzip2InputStream::FillBuffer() size_t Bzip2InputStream::Read(void *ptr, size_t length) { + const ScopeUnlock unlock(mutex); + int bz_result; size_t nbytes = 0; @@ -224,4 +226,3 @@ const ArchivePlugin bz2_archive_plugin = { bz2_open, bz2_extensions, }; - |