From a5f5be8a0c5cd43139146b6e66a874fc25ab9be7 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 14 Mar 2008 14:40:31 +0000 Subject: [PATCH] attempt to try to fix mantis issue # 613, which seems to be a threading issue. Queue is only threadsafe if its a public static member, which in this case it wasn't. And we were locking it during both enqueues and dequeues. So have added those locks to a syncObject. But it still needs testing on a high load region, as that seems to be when the exception happened. --- OpenSim/Region/Environment/Types/UpdateQueue.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index ce0927ce9d..391c50c726 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -43,6 +43,8 @@ namespace OpenSim.Region.Environment.Types private List m_ids; + private object m_syncObject = new object(); + public int Count { get { return m_queue.Count; } @@ -53,21 +55,19 @@ namespace OpenSim.Region.Environment.Types m_queue = new Queue(); m_ids = new List(); } + public void Clear() { - lock (m_ids) + lock (m_syncObject) { m_ids.Clear(); - } - lock (m_queue) - { m_queue.Clear(); } } public void Enqueue(SceneObjectPart part) { - lock (m_ids) + lock (m_syncObject) { if (!m_ids.Contains(part.UUID)) { @@ -80,11 +80,11 @@ namespace OpenSim.Region.Environment.Types public SceneObjectPart Dequeue() { SceneObjectPart part = null; - if (m_queue.Count > 0) + lock (m_syncObject) { - part = m_queue.Dequeue(); - lock (m_ids) + if (m_queue.Count > 0) { + part = m_queue.Dequeue(); m_ids.Remove(part.UUID); } }