diff options
author | Justin Clark-Casey (justincc) | 2012-03-20 00:40:03 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-22 22:46:45 +0000 |
commit | 64eb4b8408ed6d305dae2ec6877b55af1f553932 (patch) | |
tree | 963240fed6c9ad85e009e465c365fd3279a4441c /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |
parent | Fixed borkness with map search introduce by my last changes to it. (diff) | |
download | opensim-SC_OLD-64eb4b8408ed6d305dae2ec6877b55af1f553932.zip opensim-SC_OLD-64eb4b8408ed6d305dae2ec6877b55af1f553932.tar.gz opensim-SC_OLD-64eb4b8408ed6d305dae2ec6877b55af1f553932.tar.bz2 opensim-SC_OLD-64eb4b8408ed6d305dae2ec6877b55af1f553932.tar.xz |
Fix crash where two scene loop threads could changes m_MeshToTriMeshMap at the same time.
Have to lock m_MeshToTriMeshMap as property is static and with more than one region two scene loops could try to manipulate at the same time.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 97890ee..1f79cd8 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -842,17 +842,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
842 | mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage | 842 | mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage |
843 | 843 | ||
844 | mesh.releaseSourceMeshData(); // free up the original mesh data to save memory | 844 | mesh.releaseSourceMeshData(); // free up the original mesh data to save memory |
845 | if (m_MeshToTriMeshMap.ContainsKey(mesh)) | ||
846 | { | ||
847 | _triMeshData = m_MeshToTriMeshMap[mesh]; | ||
848 | } | ||
849 | else | ||
850 | { | ||
851 | _triMeshData = d.GeomTriMeshDataCreate(); | ||
852 | 845 | ||
853 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); | 846 | // We must lock here since m_MeshToTriMeshMap is static and multiple scene threads may call this method at |
854 | d.GeomTriMeshDataPreprocess(_triMeshData); | 847 | // the same time. |
855 | m_MeshToTriMeshMap[mesh] = _triMeshData; | 848 | lock (m_MeshToTriMeshMap) |
849 | { | ||
850 | if (m_MeshToTriMeshMap.ContainsKey(mesh)) | ||
851 | { | ||
852 | _triMeshData = m_MeshToTriMeshMap[mesh]; | ||
853 | } | ||
854 | else | ||
855 | { | ||
856 | _triMeshData = d.GeomTriMeshDataCreate(); | ||
857 | |||
858 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); | ||
859 | d.GeomTriMeshDataPreprocess(_triMeshData); | ||
860 | m_MeshToTriMeshMap[mesh] = _triMeshData; | ||
861 | } | ||
856 | } | 862 | } |
857 | 863 | ||
858 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | 864 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); |