aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-13 00:29:07 +0100
committerJustin Clark-Casey (justincc)2013-07-13 00:29:07 +0100
commitd06c85ea77f76f4d915081ed6b314d66d6d38fbf (patch)
tree7f6a27330d7f3221eacdd3b6331f997fcb7b080d /OpenSim/Region/Framework
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-d06c85ea77f76f4d915081ed6b314d66d6d38fbf.zip
opensim-SC_OLD-d06c85ea77f76f4d915081ed6b314d66d6d38fbf.tar.gz
opensim-SC_OLD-d06c85ea77f76f4d915081ed6b314d66d6d38fbf.tar.bz2
opensim-SC_OLD-d06c85ea77f76f4d915081ed6b314d66d6d38fbf.tar.xz
Reinsert PhysicsActor variable back into SOP.SubscribeForCollisionEvents() in order to avoid a race condition.
A separate PhysicsActor variable is used in case some other thread removes the PhysicsActor whilst this code is executing. If this is now impossible please revert - just adding this now whilst I remember. Also makes method comment into proper method doc.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs20
1 files changed, 12 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 830fe31..eb3af42 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4272,10 +4272,14 @@ namespace OpenSim.Region.Framework.Scenes
4272// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4272// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4273 } 4273 }
4274 4274
4275 // Subscribe for physics collision events if needed for scripts and sounds 4275 /// <summary>
4276 /// Subscribe for physics collision events if needed for scripts and sounds
4277 /// </summary>
4276 public void SubscribeForCollisionEvents() 4278 public void SubscribeForCollisionEvents()
4277 { 4279 {
4278 if (PhysActor != null) 4280 PhysicsActor pa = PhysActor;
4281
4282 if (pa != null)
4279 { 4283 {
4280 if ( 4284 if (
4281 ((AggregateScriptEvents & scriptEvents.collision) != 0) || 4285 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
@@ -4293,20 +4297,20 @@ namespace OpenSim.Region.Framework.Scenes
4293 (CollisionSound != UUID.Zero) 4297 (CollisionSound != UUID.Zero)
4294 ) 4298 )
4295 { 4299 {
4296 if (!PhysActor.SubscribedEvents()) 4300 if (!pa.SubscribedEvents())
4297 { 4301 {
4298 // If not already subscribed for event, set up for a collision event. 4302 // If not already subscribed for event, set up for a collision event.
4299 PhysActor.OnCollisionUpdate += PhysicsCollision; 4303 pa.OnCollisionUpdate += PhysicsCollision;
4300 PhysActor.SubscribeEvents(1000); 4304 pa.SubscribeEvents(1000);
4301 } 4305 }
4302 } 4306 }
4303 else 4307 else
4304 { 4308 {
4305 // There is no need to be subscribed to collisions so, if subscribed, remove subscription 4309 // There is no need to be subscribed to collisions so, if subscribed, remove subscription
4306 if (PhysActor.SubscribedEvents()) 4310 if (pa.SubscribedEvents())
4307 { 4311 {
4308 PhysActor.OnCollisionUpdate -= PhysicsCollision; 4312 pa.OnCollisionUpdate -= PhysicsCollision;
4309 PhysActor.UnSubscribeEvents(); 4313 pa.UnSubscribeEvents();
4310 } 4314 }
4311 } 4315 }
4312 } 4316 }