1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Merge pull request #21287 from peppy/fix-null-ref-persistent-endpoint-connector

Fix potential incorrect connection state resulting in null reference
This commit is contained in:
Dan Balasescu 2022-11-18 15:08:33 +09:00 committed by GitHub
commit 7e9d2ecaf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,7 +145,9 @@ namespace osu.Game.Online
private async Task onConnectionClosed(Exception? ex, CancellationToken cancellationToken)
{
isConnected.Value = false;
bool hasBeenCancelled = cancellationToken.IsCancellationRequested;
await disconnect(true);
if (ex != null)
await handleErrorAndDelay(ex, cancellationToken).ConfigureAwait(false);
@ -153,7 +155,7 @@ namespace osu.Game.Online
Logger.Log($"{ClientName} disconnected", LoggingTarget.Network);
// make sure a disconnect wasn't triggered (and this is still the active connection).
if (!cancellationToken.IsCancellationRequested)
if (!hasBeenCancelled)
await Task.Run(connect, default).ConfigureAwait(false);
}
@ -174,7 +176,9 @@ namespace osu.Game.Online
}
finally
{
isConnected.Value = false;
CurrentConnection = null;
if (takeLock)
connectionLock.Release();
}