mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Fix API getting stuck in an endless loop under a certain unauthorized scenario
This commit is contained in:
parent
7a4cfe6667
commit
78ccbcabf3
@ -148,7 +148,7 @@ namespace osu.Game.Online.API
|
||||
// The Success callback event is fired on the main thread, so we should wait for that to run before proceeding.
|
||||
// Without this, we will end up circulating this Connecting loop multiple times and queueing up many web requests
|
||||
// before actually going online.
|
||||
while (State != APIState.Online)
|
||||
while (State > APIState.Offline)
|
||||
Thread.Sleep(500);
|
||||
|
||||
break;
|
||||
@ -158,7 +158,6 @@ namespace osu.Game.Online.API
|
||||
if (authentication.RequestAccessToken() == null)
|
||||
{
|
||||
Logout(false);
|
||||
State = APIState.Offline;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -208,6 +207,14 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
HttpStatusCode statusCode = (we.Response as HttpWebResponse)?.StatusCode ?? (we.Status == WebExceptionStatus.UnknownError ? HttpStatusCode.NotAcceptable : HttpStatusCode.RequestTimeout);
|
||||
|
||||
// special cases for un-typed but useful message responses.
|
||||
switch (we.Message)
|
||||
{
|
||||
case "Unauthorized":
|
||||
statusCode = HttpStatusCode.Unauthorized;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (statusCode)
|
||||
{
|
||||
case HttpStatusCode.Unauthorized:
|
||||
@ -292,6 +299,7 @@ namespace osu.Game.Online.API
|
||||
password = null;
|
||||
authentication.Clear();
|
||||
LocalUser.Value = createGuestUser();
|
||||
State = APIState.Offline;
|
||||
}
|
||||
|
||||
private static User createGuestUser() => new User
|
||||
|
Loading…
Reference in New Issue
Block a user