From 7153284e9f71ef20660ce5d532515d25bf30b274 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Tue, 26 Sep 2023 21:25:13 -0400 Subject: [PATCH] Updated AchievementManager ResolveHash to properly lock inputs and outputs without locking during the network call. --- Source/Core/Core/AchievementManager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 61891fe8af..ed3729a738 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -518,8 +518,12 @@ AchievementManager::ResponseType AchievementManager::ResolveHash(std::array game_hash) { rc_api_resolve_hash_response_t hash_data{}; - std::string username = Config::Get(Config::RA_USERNAME); - std::string api_token = Config::Get(Config::RA_API_TOKEN); + std::string username, api_token; + { + std::lock_guard lg{m_lock}; + username = Config::Get(Config::RA_USERNAME); + api_token = Config::Get(Config::RA_API_TOKEN); + } rc_api_resolve_hash_request_t resolve_hash_request = { .username = username.c_str(), .api_token = api_token.c_str(), .game_hash = game_hash.data()}; ResponseType r_type = Request( @@ -527,6 +531,7 @@ AchievementManager::ResolveHash(std::array game_hash) rc_api_process_resolve_hash_response); if (r_type == ResponseType::SUCCESS) { + std::lock_guard lg{m_lock}; m_game_id = hash_data.game_id; INFO_LOG_FMT(ACHIEVEMENTS, "Hashed game ID {} for RetroAchievements.", m_game_id); }