mirror of
https://github.com/ppy/osu
synced 2025-01-18 20:10:49 +00:00
Fix multiple requests potentially being triggered during connect sequence
As the Success callbacks happen in a scheduled context, if the Update thread is in a stalled state, this loop can generate many unnecessary API requests.
This commit is contained in:
parent
65d1594be8
commit
808c97fcb4
@ -121,18 +121,28 @@ namespace osu.Game.Online.API
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
var userReq = new GetUserRequest();
|
||||
userReq.Success += u =>
|
||||
{
|
||||
LocalUser.Value = u;
|
||||
failureCount = 0;
|
||||
|
||||
//we're connected!
|
||||
State = APIState.Online;
|
||||
failureCount = 0;
|
||||
};
|
||||
|
||||
if (!handleRequest(userReq))
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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)
|
||||
Thread.Sleep(500);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user