A stab at brute force fixing the locking - one, make m_itemLock volatile, two,

reset the lock even if the write lock is not apparently held.
avinationmerge
Melanie Thielker 2014-09-21 19:24:15 +02:00
parent 4002cd96a5
commit 640f3f3074
1 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ namespace OpenSim.Framework
/// <value> /// <value>
/// An advanced lock for inventory data /// An advanced lock for inventory data
/// </value> /// </value>
private System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim(); private volatile System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim();
/// <summary> /// <summary>
/// Are we readlocked by the calling thread? /// Are we readlocked by the calling thread?
@ -143,8 +143,8 @@ namespace OpenSim.Framework
while (!m_itemLock.TryEnterReadLock(60000)) while (!m_itemLock.TryEnterReadLock(60000))
{ {
m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
if (m_itemLock.IsWriteLockHeld) //if (m_itemLock.IsWriteLockHeld)
{ //{
m_itemLock = new System.Threading.ReaderWriterLockSlim(); m_itemLock = new System.Threading.ReaderWriterLockSlim();
// System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
@ -153,7 +153,7 @@ namespace OpenSim.Framework
// System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
// LockedByThread = null; // LockedByThread = null;
// ReadLockers.Clear(); // ReadLockers.Clear();
} //}
} }
// ReadLockers[Thread.CurrentThread] = Environment.StackTrace; // ReadLockers[Thread.CurrentThread] = Environment.StackTrace;
} }