mirror of
https://github.com/osukey/osukey.git
synced 2025-05-07 06:37:18 +09:00
Fix potentially cyclic subscription registration if a subscription's delegate accesses Context
This commit is contained in:
parent
1f157d729d
commit
3b11235d3c
@ -88,6 +88,8 @@ namespace osu.Game.Database
|
|||||||
registerSubscription(action);
|
registerSubscription(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Assert(context != null);
|
||||||
|
|
||||||
// creating a context will ensure our schema is up-to-date and migrated.
|
// creating a context will ensure our schema is up-to-date and migrated.
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@ -261,10 +263,13 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||||
|
|
||||||
|
// Get context outside of flag update to ensure beyond doubt this can't be cyclic.
|
||||||
|
var realm = Context;
|
||||||
|
|
||||||
lock (contextLock)
|
lock (contextLock)
|
||||||
{
|
{
|
||||||
current_thread_subscriptions_allowed.Value = true;
|
current_thread_subscriptions_allowed.Value = true;
|
||||||
subscriptionActions[action] = action(Context);
|
subscriptionActions[action] = action(realm);
|
||||||
current_thread_subscriptions_allowed.Value = false;
|
current_thread_subscriptions_allowed.Value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user