Skip to content

Commit 43b6e87

Browse files
committed
input/cache/Stream: pass the correct mutex to InputCacheItem::Read()
This deadlock bug has been present ever since the very first commit 5d74b5c which added the input cache.
1 parent 80ac161 commit 43b6e87

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
ver 0.24.10 (not yet released)
2+
* input
3+
- cache: fix deadlock bug
24
* database
35
- upnp: allow building with libupnp 1.14.30 which has fixed the API breakage
46
* Windows

src/input/cache/Stream.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ CacheInputStream::Read(std::unique_lock<Mutex> &lock,
6464
#lock) and lock #InputCacheItem's mutex (from
6565
#BufferingInputStream) instead*/
6666
const ScopeUnlock unlock{lock};
67-
const std::lock_guard protect{i.mutex};
67+
std::unique_lock cache_lock{i.mutex};
6868

69-
nbytes = i.Read(lock, _offset, dest);
69+
nbytes = i.Read(cache_lock, _offset, dest);
7070
}
7171

7272
offset += nbytes;

0 commit comments

Comments
 (0)