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.
0.7.3-post-fixes
Justin Clark-Casey (justincc) 2012-03-20 00:40:03 +00:00
parent fa30ace67d
commit 64eb4b8408
1 changed files with 16 additions and 10 deletions

View File

@ -842,17 +842,23 @@ namespace OpenSim.Region.Physics.OdePlugin
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
if (m_MeshToTriMeshMap.ContainsKey(mesh))
{
_triMeshData = m_MeshToTriMeshMap[mesh];
}
else
{
_triMeshData = d.GeomTriMeshDataCreate();
d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
d.GeomTriMeshDataPreprocess(_triMeshData);
m_MeshToTriMeshMap[mesh] = _triMeshData;
// We must lock here since m_MeshToTriMeshMap is static and multiple scene threads may call this method at
// the same time.
lock (m_MeshToTriMeshMap)
{
if (m_MeshToTriMeshMap.ContainsKey(mesh))
{
_triMeshData = m_MeshToTriMeshMap[mesh];
}
else
{
_triMeshData = d.GeomTriMeshDataCreate();
d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
d.GeomTriMeshDataPreprocess(_triMeshData);
m_MeshToTriMeshMap[mesh] = _triMeshData;
}
}
// _parent_scene.waitForSpaceUnlock(m_targetSpace);