diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/TaskInventoryDictionary.cs | 89 |
1 files changed, 57 insertions, 32 deletions
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 814758a..4d07746 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs | |||
@@ -52,10 +52,10 @@ 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; | 55 | // private string WriterStack; |
56 | 56 | ||
57 | private Dictionary<Thread, string> ReadLockers = | 57 | // private Dictionary<Thread, string> ReadLockers = |
58 | new Dictionary<Thread, string>(); | 58 | // new Dictionary<Thread, string>(); |
59 | 59 | ||
60 | /// <value> | 60 | /// <value> |
61 | /// An advanced lock for inventory data | 61 | /// An advanced lock for inventory data |
@@ -98,14 +98,25 @@ namespace OpenSim.Framework | |||
98 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | 98 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); |
99 | try | 99 | try |
100 | { | 100 | { |
101 | StackTrace stackTrace = new StackTrace(); // get call stack | 101 | // That call stack is useful for end users only. RealProgrammers need a full dump. Commented. |
102 | StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) | 102 | // StackTrace stackTrace = new StackTrace(); // get call stack |
103 | // StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) | ||
104 | // | ||
105 | // // write call stack method names | ||
106 | // foreach (StackFrame stackFrame in stackFrames) | ||
107 | // { | ||
108 | // m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name | ||
109 | // } | ||
103 | 110 | ||
104 | // write call stack method names | 111 | // The below is far more useful |
105 | foreach (StackFrame stackFrame in stackFrames) | 112 | // System.Console.WriteLine("------------------------------------------"); |
106 | { | 113 | // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); |
107 | m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name | 114 | // System.Console.WriteLine("------------------------------------------"); |
108 | } | 115 | // foreach (KeyValuePair<Thread, string> kvp in ReadLockers) |
116 | // { | ||
117 | // System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name); | ||
118 | // System.Console.WriteLine("------------------------------------------"); | ||
119 | // } | ||
109 | } | 120 | } |
110 | catch | 121 | catch |
111 | {} | 122 | {} |
@@ -114,6 +125,16 @@ namespace OpenSim.Framework | |||
114 | if (m_itemLock.RecursiveWriteCount > 0) | 125 | if (m_itemLock.RecursiveWriteCount > 0) |
115 | { | 126 | { |
116 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | 127 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); |
128 | // try | ||
129 | // { | ||
130 | // System.Console.WriteLine("------------------------------------------"); | ||
131 | // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); | ||
132 | // System.Console.WriteLine("------------------------------------------"); | ||
133 | // System.Console.WriteLine("Locker's call stack:\n" + WriterStack); | ||
134 | // System.Console.WriteLine("------------------------------------------"); | ||
135 | // } | ||
136 | // catch | ||
137 | // {} | ||
117 | m_itemLock.ExitWriteLock(); | 138 | m_itemLock.ExitWriteLock(); |
118 | } | 139 | } |
119 | 140 | ||
@@ -123,15 +144,16 @@ namespace OpenSim.Framework | |||
123 | if (m_itemLock.IsWriteLockHeld) | 144 | if (m_itemLock.IsWriteLockHeld) |
124 | { | 145 | { |
125 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | 146 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); |
126 | System.Console.WriteLine("------------------------------------------"); | 147 | // System.Console.WriteLine("------------------------------------------"); |
127 | System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); | 148 | // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); |
128 | System.Console.WriteLine("------------------------------------------"); | 149 | // System.Console.WriteLine("------------------------------------------"); |
129 | System.Console.WriteLine("Locker's call stack:\n" + WriterStack); | 150 | // System.Console.WriteLine("Locker's call stack:\n" + WriterStack); |
130 | System.Console.WriteLine("------------------------------------------"); | 151 | // System.Console.WriteLine("------------------------------------------"); |
131 | LockedByThread = null; | 152 | // LockedByThread = null; |
132 | ReadLockers.Clear(); | 153 | // ReadLockers.Clear(); |
133 | } | 154 | } |
134 | } | 155 | } |
156 | // ReadLockers[Thread.CurrentThread] = Environment.StackTrace; | ||
135 | } | 157 | } |
136 | else | 158 | else |
137 | { | 159 | { |
@@ -139,6 +161,8 @@ namespace OpenSim.Framework | |||
139 | { | 161 | { |
140 | m_itemLock.ExitReadLock(); | 162 | m_itemLock.ExitReadLock(); |
141 | } | 163 | } |
164 | // if (m_itemLock.RecursiveReadCount == 0) | ||
165 | // ReadLockers.Remove(Thread.CurrentThread); | ||
142 | } | 166 | } |
143 | } | 167 | } |
144 | 168 | ||
@@ -158,6 +182,7 @@ namespace OpenSim.Framework | |||
158 | if (m_itemLock.RecursiveWriteCount > 0) | 182 | if (m_itemLock.RecursiveWriteCount > 0) |
159 | { | 183 | { |
160 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | 184 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); |
185 | |||
161 | m_itemLock.ExitWriteLock(); | 186 | m_itemLock.ExitWriteLock(); |
162 | } | 187 | } |
163 | while (!m_itemLock.TryEnterWriteLock(60000)) | 188 | while (!m_itemLock.TryEnterWriteLock(60000)) |
@@ -165,30 +190,30 @@ namespace OpenSim.Framework | |||
165 | if (m_itemLock.IsWriteLockHeld) | 190 | if (m_itemLock.IsWriteLockHeld) |
166 | { | 191 | { |
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."); | 192 | 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("------------------------------------------"); | 193 | // System.Console.WriteLine("------------------------------------------"); |
169 | System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); | 194 | // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); |
170 | System.Console.WriteLine("------------------------------------------"); | 195 | // System.Console.WriteLine("------------------------------------------"); |
171 | System.Console.WriteLine("Locker's call stack:\n" + WriterStack); | 196 | // System.Console.WriteLine("Locker's call stack:\n" + WriterStack); |
172 | System.Console.WriteLine("------------------------------------------"); | 197 | // System.Console.WriteLine("------------------------------------------"); |
173 | } | 198 | } |
174 | else | 199 | else |
175 | { | 200 | { |
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."); | 201 | 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("------------------------------------------"); | 202 | // System.Console.WriteLine("------------------------------------------"); |
178 | System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); | 203 | // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); |
179 | System.Console.WriteLine("------------------------------------------"); | 204 | // System.Console.WriteLine("------------------------------------------"); |
180 | foreach (KeyValuePair<Thread, string> kvp in ReadLockers) | 205 | // foreach (KeyValuePair<Thread, string> kvp in ReadLockers) |
181 | { | 206 | // { |
182 | System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name); | 207 | // System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name); |
183 | System.Console.WriteLine("------------------------------------------"); | 208 | // System.Console.WriteLine("------------------------------------------"); |
184 | } | 209 | // } |
185 | } | 210 | } |
186 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | 211 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); |
187 | ReadLockers.Clear(); | 212 | // ReadLockers.Clear(); |
188 | } | 213 | } |
189 | 214 | ||
190 | LockedByThread = Thread.CurrentThread; | 215 | LockedByThread = Thread.CurrentThread; |
191 | WriterStack = Environment.StackTrace; | 216 | // WriterStack = Environment.StackTrace; |
192 | } | 217 | } |
193 | else | 218 | else |
194 | { | 219 | { |