From 51debaeb47de93edec1ba10161df74a2f7f49209 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 27 Sep 2022 18:57:42 +0200 Subject: Revert "Android: Don't hold gameFileCache lock during updateAdditionalMetadata" This reverts commit fb265b610de08df5509e56beeb3dbff68f7d4396. The optimization in that commit is safe when the executor thread is writing and the GUI thread is reading, but I had failed to take into account that it's unsafe when the GUI thread is writing and the executor thread is reading. (The native UpdateAdditionalMetadata function loops through m_cached_files, which is unsafe if another thread is adding elements to m_cached_files simultaneously.) Losing out on this optimization isn't too bad, because 719930bb390ed0020b99a7942289d83218e99d69 makes it very unlikely that both threads will want the lock at the same time. --- .../dolphinemu/services/GameFileCacheManager.java | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'Source/Android/app/src/main/java') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java index b359915901..4e883413b4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java @@ -227,25 +227,24 @@ public final class GameFileCacheManager { String[] gamePaths = GameFileCache.getAllGamePaths(); - boolean changed; synchronized (sGameFileCache) { - changed = sGameFileCache.update(gamePaths); - } - if (changed) - { - updateGameFileArray(); - } + boolean changed = sGameFileCache.update(gamePaths); + if (changed) + { + updateGameFileArray(); + } - boolean additionalMetadataChanged = sGameFileCache.updateAdditionalMetadata(); - if (additionalMetadataChanged) - { - updateGameFileArray(); - } + boolean additionalMetadataChanged = sGameFileCache.updateAdditionalMetadata(); + if (additionalMetadataChanged) + { + updateGameFileArray(); + } - if (changed || additionalMetadataChanged) - { - sGameFileCache.save(); + if (changed || additionalMetadataChanged) + { + sGameFileCache.save(); + } } } -- cgit v1.2.3