From c2639bef8e981e49fef09dfd9c54442ba500e9d4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 2 Nov 2012 10:14:08 +0000 Subject: [PATCH] lock unique and uniqueReleased in same order when both locks are needed --- .../Region/Physics/UbitMeshing/Meshmerizer.cs | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs index 29fdda4af6..6e1a105bff 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs @@ -1057,25 +1057,22 @@ namespace OpenSim.Region.Physics.Meshing mesh.RefCount++; return mesh; } - } - // try to find a identical mesh on meshs recently released - lock (m_uniqueReleasedMeshes) - { - m_uniqueReleasedMeshes.TryGetValue(key, out mesh); - if (mesh != null) + // try to find a identical mesh on meshs recently released + lock (m_uniqueReleasedMeshes) { - m_uniqueReleasedMeshes.Remove(key); - lock (m_uniqueMeshes) + m_uniqueReleasedMeshes.TryGetValue(key, out mesh); + if (mesh != null) { + m_uniqueReleasedMeshes.Remove(key); try { m_uniqueMeshes.Add(key, mesh); } catch { } + mesh.RefCount = 1; + return mesh; } - mesh.RefCount = 1; - return mesh; } } return null; @@ -1108,25 +1105,22 @@ namespace OpenSim.Region.Physics.Meshing mesh.RefCount++; return mesh; } - } - // try to find a identical mesh on meshs recently released - lock (m_uniqueReleasedMeshes) - { - m_uniqueReleasedMeshes.TryGetValue(key, out mesh); - if (mesh != null) + // try to find a identical mesh on meshs recently released + lock (m_uniqueReleasedMeshes) { - m_uniqueReleasedMeshes.Remove(key); - lock (m_uniqueMeshes) + m_uniqueReleasedMeshes.TryGetValue(key, out mesh); + if (mesh != null) { + m_uniqueReleasedMeshes.Remove(key); try { m_uniqueMeshes.Add(key, mesh); } catch { } + mesh.RefCount = 1; + return mesh; } - mesh.RefCount = 1; - return mesh; } }