From 8265a88c4a4b1c18f1bc0accfde250fe47b08c50 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jul 2013 14:51:18 -0700 Subject: Throttle the viewer's requests for region handles. Apparently Kokua is requesting this for all landmarks in inventory. Not sure why. But this seems to be the root cause of the login freeze mentioned before. This commit adds a blocking queue / process thread pattern. --- OpenSim/Region/Framework/Scenes/Scene.cs | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index aa14529..355e0ee 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3103,7 +3103,6 @@ namespace OpenSim.Region.Framework.Scenes { //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; - client.OnRegionHandleRequest += RegionHandleRequest; } public virtual void SubscribeToClientNetworkEvents(IClientAPI client) @@ -3227,7 +3226,6 @@ namespace OpenSim.Region.Framework.Scenes { //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; - client.OnRegionHandleRequest -= RegionHandleRequest; } public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) @@ -4887,22 +4885,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion - public void RegionHandleRequest(IClientAPI client, UUID regionID) - { - m_log.DebugFormat("[SCENE]: RegionHandleRequest {0}", regionID); - ulong handle = 0; - if (regionID == RegionInfo.RegionID) - handle = RegionInfo.RegionHandle; - else - { - GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID); - if (r != null) - handle = r.RegionHandle; - } - - if (handle != 0) - client.SendRegionHandle(regionID, handle); - } // Commented pending deletion since this method no longer appears to do anything at all // public bool NeedSceneCacheClear(UUID agentID) -- cgit v1.1 From dd15f954997333e007dbdc81b8a2e0fcd4583aa2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Jul 2013 20:06:27 +0100 Subject: Add very basic regression test TestChildAgentSingleRegionCapabilities() which checks for addition and removal of capabilities on add/remove of child agent --- .../Scenes/Tests/ScenePresenceCapabilityTests.cs | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs new file mode 100644 index 0000000..5714042 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Timers; +using Timer = System.Timers.Timer; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.ClientStack.Linden; +using OpenSim.Region.CoreModules.Framework; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; +using OpenSim.Region.CoreModules.World.Serialiser; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + [TestFixture] + public class ScenePresenceCapabilityTests : OpenSimTestCase + { + [Test] + public void TestChildAgentSingleRegionCapabilities() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + UUID spUuid = TestHelpers.ParseTail(0x1); + + // XXX: This is not great since the use of statics will mean that this has to be manually cleaned up for + // any subsequent test. + // XXX: May replace with a mock IHttpServer later. + BaseHttpServer httpServer = new BaseHttpServer(99999); + MainServer.AddHttpServer(httpServer); + MainServer.Instance = httpServer; + + CapabilitiesModule capsMod = new CapabilitiesModule(); + TestScene scene = new SceneHelpers().SetupScene(); + SceneHelpers.SetupSceneModules(scene, capsMod); + + ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); + Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); + + // TODO: Need to add tests for other ICapabiltiesModule methods. + + scene.IncomingCloseAgent(sp.UUID, false); + Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); + + // TODO: Need to add tests for other ICapabiltiesModule methods. + } + } +} \ No newline at end of file -- cgit v1.1 From 5dbdd5f8b4856357340357394edc2f9e229a0582 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Jul 2013 00:12:48 +0100 Subject: refactor: Make stats and sim status simpler by extending BaseStreamHandler like other handlers instead of implementing the IStreamedRequestHandler interface directly --- .../Region/Framework/Scenes/RegionStatsHandler.cs | 26 +++++----------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index c11174d..726becf 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs @@ -46,47 +46,33 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.Framework.Scenes { - public class RegionStatsHandler : IStreamedRequestHandler + public class RegionStatsHandler : BaseStreamHandler { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string osRXStatsURI = String.Empty; private string osXStatsURI = String.Empty; //private string osSecret = String.Empty; private OpenSim.Framework.RegionInfo regionInfo; public string localZone = TimeZone.CurrentTimeZone.StandardName; public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); - public string Name { get { return "RegionStats"; } } - public string Description { get { return "Region Statistics"; } } - - public RegionStatsHandler(RegionInfo region_info) + public RegionStatsHandler(RegionInfo region_info) + : base("GET", "/" + Util.SHA1Hash(region_info.regionSecret), "RegionStats", "Region Statistics") { regionInfo = region_info; - osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); } - public byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + public override byte[] Handle( + string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes(Report()); } - public string ContentType + public override string ContentType { get { return "text/plain"; } } - - public string HttpMethod - { - get { return "GET"; } - } - - public string Path - { - // This is for the region and is the regionSecret hashed - get { return "/" + osRXStatsURI; } - } private string Report() { -- cgit v1.1 From 128667735291234c4655216af0fdfc6f07355e20 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 6 Jul 2013 18:37:54 -0700 Subject: Try to normalize the creatorData of scene object parts with the trailing '/'. What a nightmare this '/' is! --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 482d958..f287a34 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -505,7 +505,11 @@ namespace OpenSim.Region.Framework.Scenes CreatorID = uuid; } if (parts.Length >= 2) + { CreatorData = parts[1]; + if (!CreatorData.EndsWith("/")) + CreatorData += "/"; + } if (parts.Length >= 3) name = parts[2]; -- cgit v1.1 From e19defde36ddbd5ff90d8304c6fe3b57110f8078 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 22:03:07 +0100 Subject: Add "show caps stats by user" and "show caps stats by cap" console commands to print various counts of capability invocation by user and by cap This currently prints caps requests received and handled, so that overload of received compared to handled or deadlock can be detected. This involves making BaseStreamHandler and BaseOutputStream record the ints, which means inheritors should subclass ProcessRequest() instead of Handle() However, existing inheriting classes overriding Handle() will still work, albeit without stats recording. "show caps" becomes "show caps list" to disambiguate between show caps commands --- OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index 726becf..f208afb 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); } - public override byte[] Handle( + protected override byte[] ProcessRequest( string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes(Report()); -- cgit v1.1 From af9b17c54570a1634d078df0feb8f1b53ffb0726 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 23:52:40 +0100 Subject: minor: remove mono compiler warnings related to keyframe code --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 9 +++------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 8a40278..29652aa 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -55,7 +55,6 @@ namespace OpenSim.Region.Framework.Scenes private object m_lockObject = new object(); private object m_timerLock = new object(); private const double m_tickDuration = 50.0; - private Scene m_scene; public double TickDuration { @@ -69,8 +68,6 @@ namespace OpenSim.Region.Framework.Scenes m_timer.AutoReset = true; m_timer.Elapsed += OnTimer; - m_scene = scene; - m_timer.Start(); } @@ -94,13 +91,13 @@ namespace OpenSim.Region.Framework.Scenes { m.OnTimer(TickDuration); } - catch (Exception inner) + catch (Exception) { // Don't stop processing } } } - catch (Exception e) + catch (Exception) { // Keep running no matter what } @@ -157,7 +154,7 @@ namespace OpenSim.Region.Framework.Scenes [Serializable] public class KeyframeMotion { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public enum PlayMode : int { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f287a34..f361acb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -354,8 +354,6 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; - private KeyframeMotion m_keyframeMotion = null; - public KeyframeMotion KeyframeMotion { get; set; -- cgit v1.1 From 67e500383eb024fe4dd2681d0c5d902f289b65d8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 9 Jul 2013 14:12:52 -0700 Subject: Put guards on a bunch of exception-inducing code, as seen in logs from load test. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +++- OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 6 ++++++ OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 355e0ee..54956ee 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3687,7 +3687,9 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", sp.Name, sp.UUID, RegionInfo.RegionName); - sp.ControllingClient.Close(true); + if (sp.ControllingClient != null) + sp.ControllingClient.Close(true); + sp = null; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index dcb62f8..527ca35 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -67,6 +67,12 @@ namespace OpenSim.Region.Framework.Scenes { int scriptsStarted = 0; + if (m_scene == null) + { + m_log.DebugFormat("[PRIM INVENTORY]: m_scene is null. Unable to create script instances"); + return 0; + } + // Don't start scripts if they're turned off in the region! if (!m_scene.RegionInfo.RegionSettings.DisableScripts) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7dba7c8..3f223a3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -553,7 +553,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void StopScriptInstance(TaskInventoryItem item) { - m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID); + if (m_part.ParentGroup.Scene != null) + m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID); // At the moment, even stopped scripts are counted as active, which is probably wrong. // m_part.ParentGroup.AddActiveScriptCount(-1); -- cgit v1.1 From 7c2e4786ce9b85459b8c8973f658aa9a221925dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Jul 2013 23:19:55 +0100 Subject: minor: remove some regression test logging switches accidentally left uncommented. --- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index 5714042..b6fb730 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestChildAgentSingleRegionCapabilities() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID spUuid = TestHelpers.ParseTail(0x1); -- cgit v1.1 From 1909ee70f8f3df6558ce2abfc8b1d03fc5565a63 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 11 Jul 2013 16:57:07 -0700 Subject: Centralize duplicated code in SceneObjectPart for subscribing to collision events. Improve logic for knowing when to add processing routine to physics actor. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 97 ++++++++++------------ 1 file changed, 43 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f361acb..830fe31 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4213,31 +4213,12 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysics(UsePhysics, SetPhantom, false); pa = PhysActor; - if (pa != null) { pa.SetMaterial(Material); DoPhysicsPropertyUpdate(UsePhysics, true); - - if ( - ((AggregateScriptEvents & scriptEvents.collision) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - (CollisionSound != UUID.Zero) - ) - { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); - } + + SubscribeForCollisionEvents(); } } else // it already has a physical representation @@ -4291,6 +4272,46 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); } + // Subscribe for physics collision events if needed for scripts and sounds + public void SubscribeForCollisionEvents() + { + if (PhysActor != null) + { + if ( + ((AggregateScriptEvents & scriptEvents.collision) != 0) || + ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || + ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + (CollisionSound != UUID.Zero) + ) + { + if (!PhysActor.SubscribedEvents()) + { + // If not already subscribed for event, set up for a collision event. + PhysActor.OnCollisionUpdate += PhysicsCollision; + PhysActor.SubscribeEvents(1000); + } + } + else + { + // There is no need to be subscribed to collisions so, if subscribed, remove subscription + if (PhysActor.SubscribedEvents()) + { + PhysActor.OnCollisionUpdate -= PhysicsCollision; + PhysActor.UnSubscribeEvents(); + } + } + } + } + /// /// Adds this part to the physics scene. /// @@ -4680,39 +4701,7 @@ namespace OpenSim.Region.Framework.Scenes objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; } - PhysicsActor pa = PhysActor; - - if ( - ((AggregateScriptEvents & scriptEvents.collision) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - (CollisionSound != UUID.Zero) - ) - { - // subscribe to physics updates. - if (pa != null) - { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); - } - } - else - { - if (pa != null) - { - pa.UnSubscribeEvents(); - pa.OnCollisionUpdate -= PhysicsCollision; - } - } + SubscribeForCollisionEvents(); //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) //{ -- cgit v1.1 From d06c85ea77f76f4d915081ed6b314d66d6d38fbf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 13 Jul 2013 00:29:07 +0100 Subject: 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. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework') 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 // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); } - // Subscribe for physics collision events if needed for scripts and sounds + /// + /// Subscribe for physics collision events if needed for scripts and sounds + /// public void SubscribeForCollisionEvents() { - if (PhysActor != null) + PhysicsActor pa = PhysActor; + + if (pa != null) { if ( ((AggregateScriptEvents & scriptEvents.collision) != 0) || @@ -4293,20 +4297,20 @@ namespace OpenSim.Region.Framework.Scenes (CollisionSound != UUID.Zero) ) { - if (!PhysActor.SubscribedEvents()) + if (!pa.SubscribedEvents()) { // If not already subscribed for event, set up for a collision event. - PhysActor.OnCollisionUpdate += PhysicsCollision; - PhysActor.SubscribeEvents(1000); + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(1000); } } else { // There is no need to be subscribed to collisions so, if subscribed, remove subscription - if (PhysActor.SubscribedEvents()) + if (pa.SubscribedEvents()) { - PhysActor.OnCollisionUpdate -= PhysicsCollision; - PhysActor.UnSubscribeEvents(); + pa.OnCollisionUpdate -= PhysicsCollision; + pa.UnSubscribeEvents(); } } } -- cgit v1.1 From a412b1d6823141129bef3ab906c6590eb6a81c72 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 09:46:58 -0700 Subject: Moved SendInitialDataToMe to earlier in CompleteMovement. Moved TriggerOnMakeRootAgent to the end of CompleteMovement. Justin, if you read this, there's a long story here. Some time ago you placed SendInitialDataToMe at the very beginning of client creation (in LLUDPServer). That is problematic, as we discovered relatively recently: on TPs, as soon as the client starts getting data from child agents, it starts requesting resources back *from the simulator where its root agent is*. We found this to be the problem behind meshes missing on HG TPs (because the viewer was requesting the meshes of the receiving sim from the departing grid). But this affects much more than meshes and HG TPs. It may also explain cloud avatars after a local TP: baked textures are only stored in the simulator, so if a child agent receives a UUID of a baked texture in the destination sim and requests that texture from the departing sim where the root agent is, it will fail to get that texture. Bottom line: we need to delay sending the new simulator data to the viewer until we are absolutely sure that the viewer knows that its main agent is in a new sim. Hence, moving it to CompleteMovement. Now I am trying to tune the initial rez delay that we all experience in the CC. I think that when I fixed the issue described above, I may have moved SendInitialDataToMe to much later than it should be, so now I'm moving to earlier in CompleteMovement. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 774546c..bd4f68e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1010,7 +1010,9 @@ namespace OpenSim.Region.Framework.Scenes // recorded, which stops the input from being processed. MovementFlag = 0; - m_scene.EventManager.TriggerOnMakeRootAgent(this); + // DIVA NOTE: I moved TriggerOnMakeRootAgent out of here and into the end of + // CompleteMovement. We don't want modules doing heavy computation before CompleteMovement + // is over. } public int GetStateSource() @@ -1327,10 +1329,15 @@ namespace OpenSim.Region.Framework.Scenes bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); MakeRootAgent(AbsolutePosition, flying); ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); + // Remember in HandleUseCircuitCode, we delayed this to here + // This will also send the initial data to clients when TP to a neighboring region. + // Not ideal, but until we know we're TP-ing from a neighboring region, there's not much we can do + if (m_teleportFlags > 0) + SendInitialDataToMe(); // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); - if ((m_callbackURI != null) && !m_callbackURI.Equals("")) + if (!string.IsNullOrEmpty(m_callbackURI)) { // We cannot sleep here since this would hold up the inbound packet processing thread, as // CompleteMovement() is executed synchronously. However, it might be better to delay the release @@ -1358,9 +1365,6 @@ namespace OpenSim.Region.Framework.Scenes // Create child agents in neighbouring regions if (openChildAgents && !IsChildAgent) { - // Remember in HandleUseCircuitCode, we delayed this to here - SendInitialDataToMe(); - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); @@ -1382,6 +1386,11 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + + // DIVA NOTE: moved this here from MakeRoot. We don't want modules making heavy + // computations before CompleteMovement is over + m_scene.EventManager.TriggerOnMakeRootAgent(this); + } /// -- cgit v1.1 From ff4ad60207431427e26a365df1ff28aa380faf12 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 10:05:11 -0700 Subject: Same issue as previous commit. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bd4f68e..fcb841a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2694,15 +2694,16 @@ namespace OpenSim.Region.Framework.Scenes // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) - SendOtherAgentsAvatarDataToMe(); - SendOtherAgentsAppearanceToMe(); - EntityBase[] entities = Scene.Entities.GetEntities(); foreach(EntityBase e in entities) { if (e != null && e is SceneObjectGroup) ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); } + + SendOtherAgentsAvatarDataToMe(); + SendOtherAgentsAppearanceToMe(); + }); } -- cgit v1.1 From 3a26e366d2829c2f66a8aa22158bd0905f0894de Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 10:35:41 -0700 Subject: This commit effectively reverses the previous one, but it's just to log that we found the root of the rez delay: the priority scheme BestAvatarResponsiveness, which is currently the default, was the culprit. Changing it to FrontBack made the region rez be a lot more natural. BestAvatarResponsiveness introduces the region rez delay in cases where the region is full of avatars with lots of attachments, which is the case in CC load tests. In that case, the inworld prims are sent only after all avatar attachments are sent. Not recommended for regions with heavy avatar traffic! --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fcb841a..9f8ada3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2694,16 +2694,16 @@ namespace OpenSim.Region.Framework.Scenes // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) + SendOtherAgentsAvatarDataToMe(); + SendOtherAgentsAppearanceToMe(); + EntityBase[] entities = Scene.Entities.GetEntities(); - foreach(EntityBase e in entities) + foreach (EntityBase e in entities) { if (e != null && e is SceneObjectGroup) ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); } - SendOtherAgentsAvatarDataToMe(); - SendOtherAgentsAppearanceToMe(); - }); } -- cgit v1.1 From 682537738008746f0aca22954902f3a4dfbdc95f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 11:11:18 -0700 Subject: Trying to reduce CPU usage on logins and TPs: trying radical elimination of all FireAndForgets throughout CompleteMovement. There were 4. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 ++++++++++-------------- 1 file changed, 26 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9f8ada3..4d796fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -958,14 +958,7 @@ namespace OpenSim.Region.Framework.Scenes // Viewers which have a current outfit folder will actually rez their own attachments. However, // viewers without (e.g. v1 viewers) will not, so we still need to make this call. if (Scene.AttachmentsModule != null) - Util.FireAndForget( - o => - { -// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) -// System.Threading.Thread.Sleep(7000); - - Scene.AttachmentsModule.RezAttachments(this); - }); + Scene.AttachmentsModule.RezAttachments(this); } else { @@ -1362,18 +1355,6 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); - // Create child agents in neighbouring regions - if (openChildAgents && !IsChildAgent) - { - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); - - IFriendsModule friendsModule = m_scene.RequestModuleInterface(); - if (friendsModule != null) - friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - } - // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. // This may be due to viewer code or it may be something we're not doing properly simulator side. @@ -1383,6 +1364,19 @@ namespace OpenSim.Region.Framework.Scenes sog.ScheduleGroupForFullUpdate(); } + // Create child agents in neighbouring regions + if (openChildAgents && !IsChildAgent) + { + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + m_agentTransfer.EnableChildAgents(this); // this can take a while... several seconds + + } + // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); @@ -2689,22 +2683,20 @@ namespace OpenSim.Region.Framework.Scenes public void SendInitialDataToMe() { // Send all scene object to the new client - Util.FireAndForget(delegate + + // we created a new ScenePresence (a new child agent) in a fresh region. + // Request info about all the (root) agents in this region + // Note: This won't send data *to* other clients in that region (children don't send) + SendOtherAgentsAvatarDataToMe(); + SendOtherAgentsAppearanceToMe(); + + EntityBase[] entities = Scene.Entities.GetEntities(); + foreach (EntityBase e in entities) { - // we created a new ScenePresence (a new child agent) in a fresh region. - // Request info about all the (root) agents in this region - // Note: This won't send data *to* other clients in that region (children don't send) - SendOtherAgentsAvatarDataToMe(); - SendOtherAgentsAppearanceToMe(); - - EntityBase[] entities = Scene.Entities.GetEntities(); - foreach (EntityBase e in entities) - { - if (e != null && e is SceneObjectGroup) - ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); - } + if (e != null && e is SceneObjectGroup) + ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); + } - }); } /// -- cgit v1.1 From bc405a6a349f4d2be3f79afe7e8a88738339ef1f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 11:30:37 -0700 Subject: That didn't fix the problem. Revert "Trying to reduce CPU usage on logins and TPs: trying radical elimination of all FireAndForgets throughout CompleteMovement. There were 4." This reverts commit 682537738008746f0aca22954902f3a4dfbdc95f. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 ++++++++++++++---------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4d796fe..9f8ada3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -958,7 +958,14 @@ namespace OpenSim.Region.Framework.Scenes // Viewers which have a current outfit folder will actually rez their own attachments. However, // viewers without (e.g. v1 viewers) will not, so we still need to make this call. if (Scene.AttachmentsModule != null) - Scene.AttachmentsModule.RezAttachments(this); + Util.FireAndForget( + o => + { +// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) +// System.Threading.Thread.Sleep(7000); + + Scene.AttachmentsModule.RezAttachments(this); + }); } else { @@ -1355,26 +1362,25 @@ namespace OpenSim.Region.Framework.Scenes ValidateAndSendAppearanceAndAgentData(); - // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region - // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. - // This may be due to viewer code or it may be something we're not doing properly simulator side. - lock (m_attachments) - { - foreach (SceneObjectGroup sog in m_attachments) - sog.ScheduleGroupForFullUpdate(); - } - // Create child agents in neighbouring regions if (openChildAgents && !IsChildAgent) { + IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); + if (m_agentTransfer != null) + Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } - IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); - if (m_agentTransfer != null) - m_agentTransfer.EnableChildAgents(this); // this can take a while... several seconds - + // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region + // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work. + // This may be due to viewer code or it may be something we're not doing properly simulator side. + lock (m_attachments) + { + foreach (SceneObjectGroup sog in m_attachments) + sog.ScheduleGroupForFullUpdate(); } // m_log.DebugFormat( @@ -2683,20 +2689,22 @@ namespace OpenSim.Region.Framework.Scenes public void SendInitialDataToMe() { // Send all scene object to the new client - - // we created a new ScenePresence (a new child agent) in a fresh region. - // Request info about all the (root) agents in this region - // Note: This won't send data *to* other clients in that region (children don't send) - SendOtherAgentsAvatarDataToMe(); - SendOtherAgentsAppearanceToMe(); - - EntityBase[] entities = Scene.Entities.GetEntities(); - foreach (EntityBase e in entities) + Util.FireAndForget(delegate { - if (e != null && e is SceneObjectGroup) - ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); - } + // we created a new ScenePresence (a new child agent) in a fresh region. + // Request info about all the (root) agents in this region + // Note: This won't send data *to* other clients in that region (children don't send) + SendOtherAgentsAvatarDataToMe(); + SendOtherAgentsAppearanceToMe(); + + EntityBase[] entities = Scene.Entities.GetEntities(); + foreach (EntityBase e in entities) + { + if (e != null && e is SceneObjectGroup) + ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); + } + }); } /// -- cgit v1.1 From 5a1d6727e15623af4700058d516cabf03fb910ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 11:39:17 -0700 Subject: Some more debug to see how many threads are available. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9f8ada3..11b15a7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1383,6 +1383,8 @@ namespace OpenSim.Region.Framework.Scenes sog.ScheduleGroupForFullUpdate(); } + m_log.DebugFormat("[SCENE PRESENCE]: ({0}) Available threads: {1}", Name, Util.FireAndForgetCount()); + // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); -- cgit v1.1 From b4f1b9acf65f9e782d56602e60c58be6145c5cca Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 21:28:46 -0700 Subject: Guard against unauthorized agent deletes. --- OpenSim/Region/Framework/Scenes/Scene.cs | 26 +++++++++++++++++----- .../Framework/Scenes/SceneCommunicationService.cs | 8 +++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++- 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 54956ee..becea1f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3452,7 +3452,7 @@ namespace OpenSim.Region.Framework.Scenes regions.Remove(RegionInfo.RegionHandle); // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. - m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); + m_sceneGridService.SendCloseChildAgentConnections(agentID, Util.Md5Hash(acd.Id0), regions); } m_eventManager.TriggerClientClosed(agentID, this); @@ -4277,6 +4277,25 @@ namespace OpenSim.Region.Framework.Scenes return false; } + /// + /// Authenticated close (via network) + /// + /// + /// + /// + /// + public bool IncomingCloseAgent(UUID agentID, bool force, string auth_token) + { + //m_log.DebugFormat("[SCENE]: Processing incoming close agent {0} in region {1} with auth_token {2}", agentID, RegionInfo.RegionName, auth_token); + + // Check that the auth_token is valid + AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID); + if (acd != null && Util.Md5Hash(acd.Id0) == auth_token) + return IncomingCloseAgent(agentID, force); + else + m_log.ErrorFormat("[SCENE]: Request to close agent {0} with invalid authorization token {1}", agentID, auth_token); + return false; + } /// /// Tell a single agent to disconnect from the region. @@ -4292,12 +4311,9 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); if (presence != null) - { presence.ControllingClient.Close(force); - return true; - } - // Agent not here + // Agent not here return false; } diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 8238e23..77889fa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -197,7 +197,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Closes a child agent on a given region /// - protected void SendCloseChildAgent(UUID agentID, ulong regionHandle) + protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token) { // let's do our best, but there's not much we can do if the neighbour doesn't accept. @@ -210,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName); - m_scene.SimulationService.CloseAgent(destination, agentID); + m_scene.SimulationService.CloseAgent(destination, agentID, auth_token); } /// @@ -219,14 +219,14 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void SendCloseChildAgentConnections(UUID agentID, List regionslst) + public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List regionslst) { foreach (ulong handle in regionslst) { // We must take a copy here since handle is acts like a reference when used in an iterator. // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. ulong handleCopy = handle; - Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy); }); + Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 11b15a7..5991a34 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3167,7 +3167,11 @@ namespace OpenSim.Region.Framework.Scenes { m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); - m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); + AgentCircuitData acd = Scene.AuthenticateHandler.GetAgentCircuitData(UUID); + string auth = string.Empty; + if (acd != null) + auth = Util.Md5Hash(acd.Id0); + m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, auth, byebyeRegions); } foreach (ulong handle in byebyeRegions) -- cgit v1.1 From a2ee887c6d4cc0756b808353ad0183b1e7e29b74 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 22:32:52 -0700 Subject: Deleted a line too many --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index becea1f..264aaa8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4311,7 +4311,10 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); if (presence != null) + { presence.ControllingClient.Close(force); + return true; + } // Agent not here return false; -- cgit v1.1 From e4f741f0062dfe948e071a88f643f96931140f67 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 22:52:51 -0700 Subject: This should fix the failing test. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 264aaa8..155054a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3452,7 +3452,7 @@ namespace OpenSim.Region.Framework.Scenes regions.Remove(RegionInfo.RegionHandle); // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. - m_sceneGridService.SendCloseChildAgentConnections(agentID, Util.Md5Hash(acd.Id0), regions); + m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.Id0 != null ? Util.Md5Hash(acd.Id0) : string.Empty, regions); } m_eventManager.TriggerClientClosed(agentID, this); @@ -4308,7 +4308,6 @@ namespace OpenSim.Region.Framework.Scenes public bool IncomingCloseAgent(UUID agentID, bool force) { //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); - ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); if (presence != null) { -- cgit v1.1 From fcb0349d565154926be87144d374c7b6d6476eab Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 13 Jul 2013 23:01:41 -0700 Subject: And this fixes the other failing tests. Justin, the thread pool is not being initialized in the tests! --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5991a34..b7ce173 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1383,8 +1383,6 @@ namespace OpenSim.Region.Framework.Scenes sog.ScheduleGroupForFullUpdate(); } - m_log.DebugFormat("[SCENE PRESENCE]: ({0}) Available threads: {1}", Name, Util.FireAndForgetCount()); - // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); -- cgit v1.1 From f3b3e21dea98b4ea974ae7649a63d00b69e6dfed Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 07:28:40 -0700 Subject: Change the auth token to be the user's sessionid. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 155054a..ea7081c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3452,7 +3452,7 @@ namespace OpenSim.Region.Framework.Scenes regions.Remove(RegionInfo.RegionHandle); // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. - m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.Id0 != null ? Util.Md5Hash(acd.Id0) : string.Empty, regions); + m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions); } m_eventManager.TriggerClientClosed(agentID, this); @@ -4290,7 +4290,7 @@ namespace OpenSim.Region.Framework.Scenes // Check that the auth_token is valid AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID); - if (acd != null && Util.Md5Hash(acd.Id0) == auth_token) + if (acd != null && acd.SessionID.ToString() == auth_token) return IncomingCloseAgent(agentID, force); else m_log.ErrorFormat("[SCENE]: Request to close agent {0} with invalid authorization token {1}", agentID, auth_token); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b7ce173..c5cca22 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3168,7 +3168,7 @@ namespace OpenSim.Region.Framework.Scenes AgentCircuitData acd = Scene.AuthenticateHandler.GetAgentCircuitData(UUID); string auth = string.Empty; if (acd != null) - auth = Util.Md5Hash(acd.Id0); + auth = acd.SessionID.ToString(); m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, auth, byebyeRegions); } -- cgit v1.1 From c61ff917ef99a00d4062f264ed10c2a662585e8a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 09:21:28 -0700 Subject: Authenticate ChildAgentUpdate too. --- OpenSim/Region/Framework/Scenes/Scene.cs | 42 +++++++++++++++--------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +- 2 files changed, 29 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ea7081c..b07faa2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4202,10 +4202,18 @@ namespace OpenSim.Region.Framework.Scenes if (childAgentUpdate != null) { - childAgentUpdate.ChildAgentDataUpdate(cAgentData); - return true; + if (cAgentData.SessionID == childAgentUpdate.ControllingClient.SessionId) + { + childAgentUpdate.ChildAgentDataUpdate(cAgentData); + return true; + } + else + { + m_log.WarnFormat("[SCENE]: Attempt to update agent {0} with invalid session id {1}", childAgentUpdate.UUID, cAgentData.SessionID); + Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}", + childAgentUpdate.UUID, childAgentUpdate.ControllingClient.SessionId, cAgentData.SessionID)); + } } - return false; } @@ -4221,20 +4229,24 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) { - // I can't imagine *yet* why we would get an update if the agent is a root agent.. - // however to avoid a race condition crossing borders.. - if (childAgentUpdate.IsChildAgent) + if (childAgentUpdate.ControllingClient.SessionId == cAgentData.SessionID) { - uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); - uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); - uint tRegionX = RegionInfo.RegionLocX; - uint tRegionY = RegionInfo.RegionLocY; - //Send Data to ScenePresence - childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); - // Not Implemented: - //TODO: Do we need to pass the message on to one of our neighbors? + // I can't imagine *yet* why we would get an update if the agent is a root agent.. + // however to avoid a race condition crossing borders.. + if (childAgentUpdate.IsChildAgent) + { + uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); + uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); + uint tRegionX = RegionInfo.RegionLocX; + uint tRegionY = RegionInfo.RegionLocY; + //Send Data to ScenePresence + childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); + // Not Implemented: + //TODO: Do we need to pass the message on to one of our neighbors? + } } - + else + m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}", childAgentUpdate.UUID, cAgentData.SessionID); return true; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c5cca22..990ef6e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2927,7 +2927,7 @@ namespace OpenSim.Region.Framework.Scenes cadu.Velocity = Velocity; AgentPosition agentpos = new AgentPosition(); - agentpos.CopyFrom(cadu); + agentpos.CopyFrom(cadu, ControllingClient.SessionId); // Let's get this out of the update loop Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); }); @@ -3266,6 +3266,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.AgentID = UUID; cAgent.RegionID = Scene.RegionInfo.RegionID; + cAgent.SessionID = ControllingClient.SessionId; cAgent.Position = AbsolutePosition; cAgent.Velocity = m_velocity; -- cgit v1.1 From 98f59ffed59d33c3737787bff85a72fde545fc94 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 09:22:55 -0700 Subject: Fix broken tests -- the test setup was wrong... sigh. --- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index 5a72239..5df9aba 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs @@ -112,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; + moveArgs.SessionID = acd.SessionID; originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); -- cgit v1.1 From c8dcb8474d0b0698168863328e61a6929bb0770f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 10:26:05 -0700 Subject: Let's go easy on authenticating ChildAgentUpdates, otherwise this will be chaotic while ppl are using different versions of opensim. Warning only, but no enforcement. --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b07faa2..9cfe869 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4202,17 +4202,15 @@ namespace OpenSim.Region.Framework.Scenes if (childAgentUpdate != null) { - if (cAgentData.SessionID == childAgentUpdate.ControllingClient.SessionId) + if (cAgentData.SessionID != childAgentUpdate.ControllingClient.SessionId) { - childAgentUpdate.ChildAgentDataUpdate(cAgentData); - return true; - } - else - { - m_log.WarnFormat("[SCENE]: Attempt to update agent {0} with invalid session id {1}", childAgentUpdate.UUID, cAgentData.SessionID); + m_log.WarnFormat("[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).", childAgentUpdate.UUID, cAgentData.SessionID); Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}", childAgentUpdate.UUID, childAgentUpdate.ControllingClient.SessionId, cAgentData.SessionID)); } + + childAgentUpdate.ChildAgentDataUpdate(cAgentData); + return true; } return false; } -- cgit v1.1