aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/TaskInventoryDictionary.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/TaskInventoryDictionary.cs')
-rw-r--r--OpenSim/Framework/TaskInventoryDictionary.cs36
1 files changed, 33 insertions, 3 deletions
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index 940e567..814758a 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -52,6 +52,11 @@ namespace OpenSim.Framework
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private Thread LockedByThread; 54 private Thread LockedByThread;
55 private string WriterStack;
56
57 private Dictionary<Thread, string> ReadLockers =
58 new Dictionary<Thread, string>();
59
55 /// <value> 60 /// <value>
56 /// An advanced lock for inventory data 61 /// An advanced lock for inventory data
57 /// </value> 62 /// </value>
@@ -118,6 +123,13 @@ namespace OpenSim.Framework
118 if (m_itemLock.IsWriteLockHeld) 123 if (m_itemLock.IsWriteLockHeld)
119 { 124 {
120 m_itemLock = new System.Threading.ReaderWriterLockSlim(); 125 m_itemLock = new System.Threading.ReaderWriterLockSlim();
126 System.Console.WriteLine("------------------------------------------");
127 System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
128 System.Console.WriteLine("------------------------------------------");
129 System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
130 System.Console.WriteLine("------------------------------------------");
131 LockedByThread = null;
132 ReadLockers.Clear();
121 } 133 }
122 } 134 }
123 } 135 }
@@ -150,15 +162,33 @@ namespace OpenSim.Framework
150 } 162 }
151 while (!m_itemLock.TryEnterWriteLock(60000)) 163 while (!m_itemLock.TryEnterWriteLock(60000))
152 { 164 {
153 m_log.Error("Thread lock detected while trying to aquire WRITE 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.");
154 System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
155 if (m_itemLock.IsWriteLockHeld) 165 if (m_itemLock.IsWriteLockHeld)
156 { 166 {
157 m_itemLock = new System.Threading.ReaderWriterLockSlim(); 167 m_log.Error("Thread lock detected while trying to aquire WRITE 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.");
168 System.Console.WriteLine("------------------------------------------");
169 System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
170 System.Console.WriteLine("------------------------------------------");
171 System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
172 System.Console.WriteLine("------------------------------------------");
173 }
174 else
175 {
176 m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by a reader. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
177 System.Console.WriteLine("------------------------------------------");
178 System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
179 System.Console.WriteLine("------------------------------------------");
180 foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
181 {
182 System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
183 System.Console.WriteLine("------------------------------------------");
184 }
158 } 185 }
186 m_itemLock = new System.Threading.ReaderWriterLockSlim();
187 ReadLockers.Clear();
159 } 188 }
160 189
161 LockedByThread = Thread.CurrentThread; 190 LockedByThread = Thread.CurrentThread;
191 WriterStack = Environment.StackTrace;
162 } 192 }
163 else 193 else
164 { 194 {