1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:13:21 +08:00

Merge pull request #11893 from peppy/fix-request-queue-reference-holding

Fix requests being indefinitely queued when user is offline
This commit is contained in:
Dan Balasescu 2021-02-24 23:07:02 +09:00 committed by GitHub
commit a7d10630e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -381,7 +381,13 @@ namespace osu.Game.Online.API
public void Queue(APIRequest request)
{
lock (queue) queue.Enqueue(request);
lock (queue)
{
if (state.Value == APIState.Offline)
return;
queue.Enqueue(request);
}
}
private void flushQueue(bool failOldRequests = true)
@ -402,8 +408,6 @@ namespace osu.Game.Online.API
public void Logout()
{
flushQueue();
password = null;
authentication.Clear();
@ -415,6 +419,7 @@ namespace osu.Game.Online.API
});
state.Value = APIState.Offline;
flushQueue();
}
private static User createGuestUser() => new GuestUser();

View File

@ -15,6 +15,8 @@ namespace osu.Game.Screens.Ranking
{
public class SoloResultsScreen : ResultsScreen
{
private GetScoresRequest getScoreRequest;
[Resolved]
private RulesetStore rulesets { get; set; }
@ -28,9 +30,16 @@ namespace osu.Game.Screens.Ranking
if (Score.Beatmap.OnlineBeatmapID == null || Score.Beatmap.Status <= BeatmapSetOnlineStatus.Pending)
return null;
var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset);
req.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineScoreID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets)));
return req;
getScoreRequest = new GetScoresRequest(Score.Beatmap, Score.Ruleset);
getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineScoreID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets)));
return getScoreRequest;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
getScoreRequest?.Cancel();
}
}
}