From e158a45b09a2706df4b623bd4d264724dc58e0a5 Mon Sep 17 00:00:00 2001
From: dan miller
Date: Thu, 30 Aug 2007 23:23:44 +0000
Subject: danx0r (first checkin!) fixes OdePlugin.cs RemovePrim() lock bug

---
 OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 3cc690d..62b6fb7 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -144,8 +144,11 @@ namespace OpenSim.Region.Physics.OdePlugin
         {
             if (prim is OdePrim)
             {
-                d.GeomDestroy(((OdePrim)prim).prim_geom);
-                this._prims.Remove((OdePrim)prim);
+                lock (OdeLock)
+                {
+                    d.GeomDestroy(((OdePrim)prim).prim_geom);
+                    this._prims.Remove((OdePrim)prim);
+                }
             }
         }
 
@@ -221,10 +224,10 @@ namespace OpenSim.Region.Physics.OdePlugin
                 int y = i >> 8;
                 this._heightmap[i] = (double)heightMap[x * 256 + y];
             }
-            IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
 
             lock (OdeLock)
             {
+                IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
                 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
                 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
                 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
@@ -427,9 +430,9 @@ namespace OpenSim.Region.Physics.OdePlugin
             _size = size;
             _acceleration = new PhysicsVector();
             _orientation = rotation;
-            prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z);
             lock (OdeScene.OdeLock)
             {
+                prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z);
                 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
                 d.Quaternion myrot = new d.Quaternion();
                 myrot.W = rotation.w;
-- 
cgit v1.1