mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Fix web requests not getting correctly handled on first connection
This commit is contained in:
parent
0b5f3c00bf
commit
00998d5443
@ -141,7 +141,7 @@ namespace osu.Game.Online.API
|
|||||||
State = APIState.Online;
|
State = APIState.Online;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!handleRequest(userReq))
|
if (!handleRequest(userReq, out _))
|
||||||
{
|
{
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
continue;
|
continue;
|
||||||
@ -170,11 +170,15 @@ namespace osu.Game.Online.API
|
|||||||
lock (queue)
|
lock (queue)
|
||||||
{
|
{
|
||||||
if (queue.Count == 0) break;
|
if (queue.Count == 0) break;
|
||||||
req = queue.Dequeue();
|
req = queue.Peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle failures better
|
// TODO: handle failures better
|
||||||
handleRequest(req);
|
handleRequest(req, out var removeFromQueue);
|
||||||
|
|
||||||
|
if (removeFromQueue)
|
||||||
|
lock (queue)
|
||||||
|
queue.Dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(50);
|
Thread.Sleep(50);
|
||||||
@ -193,9 +197,11 @@ namespace osu.Game.Online.API
|
|||||||
/// Handle a single API request.
|
/// Handle a single API request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="req">The request.</param>
|
/// <param name="req">The request.</param>
|
||||||
/// <returns>true if we should remove this request from the queue.</returns>
|
/// <returns>true if the request succeeded.</returns>
|
||||||
private bool handleRequest(APIRequest req)
|
private bool handleRequest(APIRequest req, out bool removeFromQueue)
|
||||||
{
|
{
|
||||||
|
removeFromQueue = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.Log($@"Performing request {req}", LoggingTarget.Network);
|
Logger.Log($@"Performing request {req}", LoggingTarget.Network);
|
||||||
@ -216,12 +222,12 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
catch (WebException we)
|
catch (WebException we)
|
||||||
{
|
{
|
||||||
var removeFromQueue = handleWebException(we);
|
removeFromQueue = handleWebException(we);
|
||||||
|
|
||||||
if (removeFromQueue)
|
if (removeFromQueue)
|
||||||
req.Fail(we);
|
req.Fail(we);
|
||||||
|
|
||||||
return removeFromQueue;
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -229,7 +235,7 @@ namespace osu.Game.Online.API
|
|||||||
log.Add(@"API level timeout exception was hit");
|
log.Add(@"API level timeout exception was hit");
|
||||||
|
|
||||||
req.Fail(e);
|
req.Fail(e);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user