From be6b6bf191718f7c674297a804fa1a6cb4196a5a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 2 Jan 2013 20:06:57 +0000 Subject: add a lock to CollisionEventsThisFrame --- .../Region/Physics/UbitOdePlugin/ODECharacter.cs | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index e1d694e..f7e4c1c 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -1540,8 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin { if (CollisionEventsThisFrame != null) { - CollisionEventsThisFrame.Clear(); - CollisionEventsThisFrame = null; + lock (CollisionEventsThisFrame) + { + CollisionEventsThisFrame.Clear(); + CollisionEventsThisFrame = null; + } } m_eventsubscription = 0; } @@ -1550,8 +1553,11 @@ namespace OpenSim.Region.Physics.OdePlugin { if (CollisionEventsThisFrame == null) CollisionEventsThisFrame = new CollisionEventUpdate(); - CollisionEventsThisFrame.AddCollider(CollidedWith, contact); - _parent_scene.AddCollisionEventReporting(this); + lock (CollisionEventsThisFrame) + { + CollisionEventsThisFrame.AddCollider(CollidedWith, contact); + _parent_scene.AddCollisionEventReporting(this); + } } public void SendCollisions() @@ -1559,26 +1565,29 @@ namespace OpenSim.Region.Physics.OdePlugin if (CollisionEventsThisFrame == null) return; - if (m_cureventsubscription < m_eventsubscription) - return; + lock (CollisionEventsThisFrame) + { + if (m_cureventsubscription < m_eventsubscription) + return; - m_cureventsubscription = 0; + m_cureventsubscription = 0; - int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; + int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; - if (!SentEmptyCollisionsEvent || ncolisions > 0) - { - base.SendCollisionUpdate(CollisionEventsThisFrame); - - if (ncolisions == 0) + if (!SentEmptyCollisionsEvent || ncolisions > 0) { - SentEmptyCollisionsEvent = true; - _parent_scene.RemoveCollisionEventReporting(this); - } - else - { - SentEmptyCollisionsEvent = false; - CollisionEventsThisFrame.Clear(); + base.SendCollisionUpdate(CollisionEventsThisFrame); + + if (ncolisions == 0) + { + SentEmptyCollisionsEvent = true; + _parent_scene.RemoveCollisionEventReporting(this); + } + else + { + SentEmptyCollisionsEvent = false; + CollisionEventsThisFrame.Clear(); + } } } } -- cgit v1.1