From ca7303a50a1111fe17c75af6d52ee940ac865039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 21 Dec 2021 10:55:43 +0100 Subject: [PATCH] Fix online lookup cache not clearing completed task on early return The task not being cleared in the early return path would cause `pendingRequestTask` to become stuck as a completed task, and `queryValue()` would not recreate it due to the null check there, therefore stalling all lookups forevermore until a game restart. --- osu.Game/Database/OnlineLookupCache.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/osu.Game/Database/OnlineLookupCache.cs b/osu.Game/Database/OnlineLookupCache.cs index 8a50cc486f..5eb9fa24fa 100644 --- a/osu.Game/Database/OnlineLookupCache.cs +++ b/osu.Game/Database/OnlineLookupCache.cs @@ -116,7 +116,10 @@ private void performLookup() } if (nextTaskBatch.Count == 0) + { + finishPendingTask(); return; + } // Query the values. var request = CreateRequest(nextTaskBatch.Keys.ToArray()); @@ -125,13 +128,7 @@ private void performLookup() // todo: we probably want retry logic here. api.Perform(request); - // Create a new request task if there's still more values to query. - lock (taskAssignmentLock) - { - pendingRequestTask = null; - if (pendingTasks.Count > 0) - createNewTask(); - } + finishPendingTask(); var foundValues = RetrieveResults(request); @@ -157,6 +154,17 @@ private void performLookup() } } + private void finishPendingTask() + { + // Create a new request task if there's still more values to query. + lock (taskAssignmentLock) + { + pendingRequestTask = null; + if (pendingTasks.Count > 0) + createNewTask(); + } + } + private void createNewTask() => pendingRequestTask = Task.Run(performLookup); } }