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

@ -108,10 +108,13 @@ namespace OpenSim.Framework
} }
} }
else else
{
if (m_itemLock.RecursiveReadCount>0)
{ {
m_itemLock.ExitReadLock(); m_itemLock.ExitReadLock();
} }
} }
}
/// <summary> /// <summary>
/// Lock our inventory list for writing (many can read, one can write) /// Lock our inventory list for writing (many can read, one can write)
@ -143,10 +146,13 @@ namespace OpenSim.Framework
LockedByThread = Thread.CurrentThread; LockedByThread = Thread.CurrentThread;
} }
else else
{
if (m_itemLock.RecursiveWriteCount > 0)
{ {
m_itemLock.ExitWriteLock(); m_itemLock.ExitWriteLock();
} }
} }
}
#region ICloneable Members #region ICloneable Members

View File

@ -125,10 +125,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
else else
{
if (m_partsLock.RecursiveReadCount > 0)
{ {
m_partsLock.ExitReadLock(); m_partsLock.ExitReadLock();
} }
} }
}
public void lockPartsForWrite(bool locked) public void lockPartsForWrite(bool locked)
{ {
if (locked) if (locked)
@ -154,10 +157,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
else else
{
if (m_partsLock.RecursiveWriteCount > 0)
{ {
m_partsLock.ExitWriteLock(); m_partsLock.ExitWriteLock();
} }
} }
}
public bool HasGroupChanged public bool HasGroupChanged
{ {

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

@ -149,10 +149,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
else else
{
if (m_scriptsLock.RecursiveReadCount > 0)
{ {
m_scriptsLock.ExitReadLock(); m_scriptsLock.ExitReadLock();
} }
} }
}
private void lockScriptsForWrite(bool locked) private void lockScriptsForWrite(bool locked)
{ {
if (locked) if (locked)
@ -178,10 +181,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
else else
{
if (m_scriptsLock.RecursiveWriteCount > 0)
{ {
m_scriptsLock.ExitWriteLock(); m_scriptsLock.ExitWriteLock();
} }
} }
}
public string ScriptEngineName public string ScriptEngineName
{ {