Fix to existing ReaderWriterLockSlim implementations

avinationmerge
CasperW 2009-12-06 17:23:07 +01:00
parent 1e222d52e6
commit 172e2f4e76
4 changed files with 26 additions and 7 deletions

View File

@ -109,7 +109,10 @@ namespace OpenSim.Framework
} }
else else
{ {
m_itemLock.ExitReadLock(); if (m_itemLock.RecursiveReadCount>0)
{
m_itemLock.ExitReadLock();
}
} }
} }
@ -144,7 +147,10 @@ namespace OpenSim.Framework
} }
else else
{ {
m_itemLock.ExitWriteLock(); if (m_itemLock.RecursiveWriteCount > 0)
{
m_itemLock.ExitWriteLock();
}
} }
} }

View File

@ -126,7 +126,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
m_partsLock.ExitReadLock(); if (m_partsLock.RecursiveReadCount > 0)
{
m_partsLock.ExitReadLock();
}
} }
} }
public void lockPartsForWrite(bool locked) public void lockPartsForWrite(bool locked)
@ -155,7 +158,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
m_partsLock.ExitWriteLock(); if (m_partsLock.RecursiveWriteCount > 0)
{
m_partsLock.ExitWriteLock();
}
} }
} }

View File

@ -320,17 +320,18 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_items.ContainsKey(itemId)) if (m_items.ContainsKey(itemId))
{ {
m_items.LockItemsForRead(false);
CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
} }
else else
{ {
m_items.LockItemsForRead(false);
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
itemId, m_part.Name, m_part.UUID, itemId, m_part.Name, m_part.UUID,
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
} }
m_items.LockItemsForRead(false);
} }
else else
{ {

View File

@ -150,7 +150,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
else else
{ {
m_scriptsLock.ExitReadLock(); if (m_scriptsLock.RecursiveReadCount > 0)
{
m_scriptsLock.ExitReadLock();
}
} }
} }
private void lockScriptsForWrite(bool locked) private void lockScriptsForWrite(bool locked)
@ -179,7 +182,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
else else
{ {
m_scriptsLock.ExitWriteLock(); if (m_scriptsLock.RecursiveWriteCount > 0)
{
m_scriptsLock.ExitWriteLock();
}
} }
} }