summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-01-24 09:35:45 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-24 09:35:45 +0100
commitd566da586b0de3886eba9c69e2826cef5e0c5041 (patch)
treef9404b097c18cb3aa9172d5419d19a24a95c2ef8 /src
parent6f5a92dd172c5b0e424499b0c49cca90865859f6 (diff)
Fix deadlock if a closeEvent was being processed in the event queue while clearing due to a chunk size change.
Diffstat (limited to 'src')
-rw-r--r--src/audiocacheeventhandler.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/audiocacheeventhandler.cc b/src/audiocacheeventhandler.cc
index 40e339d..001f6b5 100644
--- a/src/audiocacheeventhandler.cc
+++ b/src/audiocacheeventhandler.cc
@@ -202,7 +202,7 @@ void AudioCacheEventHandler::clearEvents()
{
if(event.eventType == EventType::Close)
{
- handleCloseEvent(event);
+ handleCloseCache(event.id); // This method does not lock.
}
}
@@ -216,17 +216,15 @@ void AudioCacheEventHandler::handleLoadNextEvent(CacheEvent& event)
void AudioCacheEventHandler::handleCloseEvent(CacheEvent& e)
{
+ std::lock_guard<std::mutex> lock(mutex);
handleCloseCache(e.id);
}
void AudioCacheEventHandler::handleCloseCache(cacheid_t cacheid)
{
auto& cache = idManager.getCache(cacheid);
- {
- std::lock_guard<std::mutex> lock(mutex);
- files.releaseFile(cache.afile->getFilename());
- }
+ files.releaseFile(cache.afile->getFilename());
delete[] cache.front;
delete[] cache.back;