mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Fix a failed BlockAllOperations
leaving update realm in unretrieved state
If the operation timed out on.. ```csharp throw new TimeoutException(@"Took too long to acquire lock"); ``` ..from an update thread, it would not restore the update context. The next call would then fail on the assert that ensures a non-null context in such cases. Can add test coverage if required.
This commit is contained in:
parent
f30894840c
commit
6f4c337a56
@ -595,8 +595,8 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
if (updateRealm == null)
|
if (updateRealm == null)
|
||||||
{
|
{
|
||||||
// null realm means the update thread has not yet retrieved its instance.
|
// null context means the update thread has not yet retrieved its context.
|
||||||
// we don't need to worry about reviving the update instance in this case, so don't bother with the SynchronizationContext.
|
// we don't need to worry about reviving the update context in this case, so don't bother with the SynchronizationContext.
|
||||||
Debug.Assert(!ThreadSafety.IsUpdateThread);
|
Debug.Assert(!ThreadSafety.IsUpdateThread);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -639,18 +639,19 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
realmCreationLock.Release();
|
restoreOperation();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InvokeOnDisposal<RealmAccess>(this, factory =>
|
return new InvokeOnDisposal(restoreOperation);
|
||||||
{
|
|
||||||
factory.realmCreationLock.Release();
|
|
||||||
Logger.Log(@"Restoring realm operations.", LoggingTarget.Database);
|
|
||||||
|
|
||||||
|
void restoreOperation()
|
||||||
|
{
|
||||||
|
Logger.Log(@"Restoring realm operations.", LoggingTarget.Database);
|
||||||
|
realmCreationLock.Release();
|
||||||
// Post back to the update thread to revive any subscriptions.
|
// Post back to the update thread to revive any subscriptions.
|
||||||
syncContext?.Post(_ => ensureUpdateRealm(), null);
|
syncContext?.Post(_ => ensureUpdateRealm(), null);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/realm/realm-dotnet/blob/32f4ebcc88b3e80a3b254412665340cd9f3bd6b5/Realm/Realm/Extensions/ReflectionExtensions.cs#L46
|
// https://github.com/realm/realm-dotnet/blob/32f4ebcc88b3e80a3b254412665340cd9f3bd6b5/Realm/Realm/Extensions/ReflectionExtensions.cs#L46
|
||||||
|
Loading…
Reference in New Issue
Block a user