diff options
author | Justin Clark-Casey (justincc) | 2014-01-16 20:23:31 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-01-16 20:23:31 +0000 |
commit | 3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a (patch) | |
tree | 1aa231493524b52135ec2e5f52a7ed9b7369527c /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Can delete the Offline Messages sent to/from a user. (diff) | |
download | opensim-SC_OLD-3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a.zip opensim-SC_OLD-3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a.tar.gz opensim-SC_OLD-3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a.tar.bz2 opensim-SC_OLD-3ffd90496a366f2b64eb8daadf63a2b6ee05ad7a.tar.xz |
Prevent duplicate invocations or race dontision in SP.CompleteMovement()
This can happen under poor network conditions if a viewer repeats the message send
If this happens, physics actors can get orphaned, which unecessarily raises physics frame times
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 49f70c4..63cca56 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -108,6 +108,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | /// <summary> | ||
112 | /// This exists to prevent race conditions between two CompleteMovement threads if the simulator is slow and | ||
113 | /// the viewer fires these in quick succession. | ||
114 | /// </summary> | ||
115 | /// <remarks> | ||
116 | /// TODO: The child -> agent transition should be folded into LifecycleState and the CompleteMovement | ||
117 | /// regulation done there. | ||
118 | /// </remarks> | ||
119 | private object m_completeMovementLock = new object(); | ||
120 | |||
111 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 121 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
112 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); | 122 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
113 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | 123 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); |
@@ -905,6 +915,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | /// <summary> | 915 | /// <summary> |
906 | /// Turns a child agent into a root agent. | 916 | /// Turns a child agent into a root agent. |
907 | /// </summary> | 917 | /// </summary> |
918 | /// <remarks> | ||
908 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the | 919 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the |
909 | /// avatar is actual in the sim. They can perform all actions. | 920 | /// avatar is actual in the sim. They can perform all actions. |
910 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, | 921 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, |
@@ -912,8 +923,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
912 | /// | 923 | /// |
913 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here | 924 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here |
914 | /// delays that crossing. | 925 | /// delays that crossing. |
915 | /// </summary> | 926 | /// </remarks> |
916 | private void MakeRootAgent(Vector3 pos, bool isFlying) | 927 | private bool MakeRootAgent(Vector3 pos, bool isFlying) |
917 | { | 928 | { |
918 | // m_log.InfoFormat( | 929 | // m_log.InfoFormat( |
919 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | 930 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", |
@@ -921,6 +932,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
921 | 932 | ||
922 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 933 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
923 | 934 | ||
935 | lock (m_completeMovementLock) | ||
936 | if (!IsChildAgent) | ||
937 | return false; | ||
938 | |||
924 | IsChildAgent = false; | 939 | IsChildAgent = false; |
925 | 940 | ||
926 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag | 941 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag |
@@ -1070,6 +1085,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1070 | 1085 | ||
1071 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1086 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1072 | 1087 | ||
1088 | return true; | ||
1073 | } | 1089 | } |
1074 | 1090 | ||
1075 | public int GetStateSource() | 1091 | public int GetStateSource() |
@@ -1443,7 +1459,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1443 | } | 1459 | } |
1444 | 1460 | ||
1445 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1461 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1446 | MakeRootAgent(AbsolutePosition, flying); | 1462 | if (!MakeRootAgent(AbsolutePosition, flying)) |
1463 | { | ||
1464 | m_log.DebugFormat( | ||
1465 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", | ||
1466 | Name, Scene.Name); | ||
1467 | |||
1468 | return; | ||
1469 | } | ||
1447 | 1470 | ||
1448 | // Tell the client that we're totally ready | 1471 | // Tell the client that we're totally ready |
1449 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 1472 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |