mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +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 ICacheManager _cacheManager;
|
||||
private readonly static object _syncLock = new object();
|
||||
private readonly static object _shellContextsWriteLock = new object();
|
||||
|
||||
private IEnumerable<ShellContext> _shellContexts;
|
||||
|
||||
@@ -158,10 +159,12 @@ namespace Orchard.Environment {
|
||||
Logger.Debug("Activating context for tenant {0}", context.Settings.Name);
|
||||
context.Shell.Activate();
|
||||
|
||||
_shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>())
|
||||
.Where(c => c.Settings.Name != context.Settings.Name)
|
||||
.Concat(new[] { context })
|
||||
.ToArray();
|
||||
lock (_shellContextsWriteLock) {
|
||||
_shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>())
|
||||
.Where(c => c.Settings.Name != context.Settings.Name)
|
||||
.Concat(new[] { context })
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
_runningShellTable.Add(context.Settings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user