Adds a lock to the MacroEngines to alleviate an error of items being added twice in high load environments.

This commit is contained in:
Casey Neehouse
2012-06-14 15:33:46 +04:00
parent 53f549826e
commit 5f2e84917a

View File

@@ -11,6 +11,8 @@ namespace umbraco.cms.businesslogic.macro
{
private static readonly Dictionary<string, Type> m_engines = new Dictionary<string, Type>();
private static readonly List<IMacroEngine> m_allEngines = new List<IMacroEngine>();
private static object locker = new object();
public MacroEngineFactory()
{
Initialize();
@@ -39,7 +41,11 @@ namespace umbraco.cms.businesslogic.macro
{
try
{
m_engines.Add(typeInstance.Name, t);
lock (locker)
{
if (!m_engines.ContainsKey(typeInstance.Name))
m_engines.Add(typeInstance.Name, t);
}
}
catch (Exception ee)
{