mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#20928: Preventing race condition when starting shells
Work Item: 20928
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Orchard.Environment {
|
|||||||
private readonly IExtensionMonitoringCoordinator _extensionMonitoringCoordinator;
|
private readonly IExtensionMonitoringCoordinator _extensionMonitoringCoordinator;
|
||||||
private readonly ICacheManager _cacheManager;
|
private readonly ICacheManager _cacheManager;
|
||||||
private readonly static object _syncLock = new object();
|
private readonly static object _syncLock = new object();
|
||||||
|
private readonly static object _shellContextsWriteLock = new object();
|
||||||
|
|
||||||
private IEnumerable<ShellContext> _shellContexts;
|
private IEnumerable<ShellContext> _shellContexts;
|
||||||
|
|
||||||
@@ -158,10 +159,12 @@ namespace Orchard.Environment {
|
|||||||
Logger.Debug("Activating context for tenant {0}", context.Settings.Name);
|
Logger.Debug("Activating context for tenant {0}", context.Settings.Name);
|
||||||
context.Shell.Activate();
|
context.Shell.Activate();
|
||||||
|
|
||||||
|
lock (_shellContextsWriteLock) {
|
||||||
_shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>())
|
_shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>())
|
||||||
.Where(c => c.Settings.Name != context.Settings.Name)
|
.Where(c => c.Settings.Name != context.Settings.Name)
|
||||||
.Concat(new[] { context })
|
.Concat(new[] { context })
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
_runningShellTable.Add(context.Settings);
|
_runningShellTable.Add(context.Settings);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user