diff options
author | Justin Clark-Casey (justincc) | 2012-03-20 00:40:03 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-20 00:40:03 +0000 |
commit | 1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4 (patch) | |
tree | 7fefb0c91ab9a6d5affac2eecf2485753ef2a802 /OpenSim/Region/Physics/OdePlugin | |
parent | Add some doc about the EventManager.OnLoginsEnabled event. (diff) | |
download | opensim-SC_OLD-1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4.zip opensim-SC_OLD-1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4.tar.gz opensim-SC_OLD-1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4.tar.bz2 opensim-SC_OLD-1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4.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 'OpenSim/Region/Physics/OdePlugin')
-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); |