1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-14 05:47:20 +08:00

Fix potentially cyclic subscription registration if a subscription's delegate accesses Context

This commit is contained in:
Dean Herbert 2022-01-21 20:45:10 +09:00
parent 1f157d729d
commit 3b11235d3c

View File

@ -88,6 +88,8 @@ namespace osu.Game.Database
registerSubscription(action);
}
Debug.Assert(context != null);
// creating a context will ensure our schema is up-to-date and migrated.
return context;
}
@ -261,10 +263,13 @@ namespace osu.Game.Database
{
Debug.Assert(ThreadSafety.IsUpdateThread);
// Get context outside of flag update to ensure beyond doubt this can't be cyclic.
var realm = Context;
lock (contextLock)
{
current_thread_subscriptions_allowed.Value = true;
subscriptionActions[action] = action(Context);
subscriptionActions[action] = action(realm);
current_thread_subscriptions_allowed.Value = false;
}
}