From bcb95774959edec55cfe757b5de2e7198f176eea Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 19 Feb 2012 12:09:57 -0500 Subject: [PATCH 1/2] Use localy defined name, TPFlags, for Constants.TeleportFlags --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 13c866d048..d2a8ad09ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3259,10 +3259,10 @@ namespace OpenSim.Region.Framework.Scenes /// also return a reason. public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) { - bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 || - (teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0); - bool viahome = ((teleportFlags & (uint)Constants.TeleportFlags.ViaHome) != 0); - bool godlike = ((teleportFlags & (uint)Constants.TeleportFlags.Godlike) != 0); + bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || + (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); + bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); + bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); reason = String.Empty; @@ -3275,9 +3275,9 @@ namespace OpenSim.Region.Framework.Scenes // Don't disable this log message - it's too helpful m_log.DebugFormat( - "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags {8}, position {9})", + "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, - agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, teleportFlags, agent.startpos); + agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); if (LoginsDisabled) { From 20c65ac438ee67ecd3f837d268e44992f13a8af6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 19 Feb 2012 12:28:07 -0800 Subject: [PATCH 2/2] A few more tweaks on position updates and create child agents. Mono hates concurrent uses of the same TCP connection, and even of the connections to the same server. So let's stop doing it. This patch makes movement much smoother when there are lots of neighbours. --- .../EntityTransfer/EntityTransferModule.cs | 12 ++++++++---- .../Scenes/SceneCommunicationService.cs | 17 ++++++++++++----- .../Region/Framework/Scenes/ScenePresence.cs | 3 ++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 928bcd0c81..6e4c0b1621 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1258,12 +1258,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) { - InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; try { - d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, - InformClientOfNeighbourCompleted, - d); + // Let's put this back at sync, so that it doesn't clog + // the network, especially for regions in the same physical server. + // We're really not in a hurry here. + InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent); + //InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + //d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, + // InformClientOfNeighbourCompleted, + // d); } catch (ArgumentOutOfRangeException) diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 58a7b2045b..c04171b9c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -140,6 +140,7 @@ namespace OpenSim.Region.Framework.Scenes icon.EndInvoke(iar); } + ExpiringCache _failedSims = new ExpiringCache(); public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence) { // This assumes that we know what our neighbors are. @@ -156,16 +157,22 @@ namespace OpenSim.Region.Framework.Scenes // that the region position is cached or performance will degrade Utils.LongToUInts(regionHandle, out x, out y); GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (! simulatorList.Contains(dest.ServerURI)) + bool v = true; + if (! simulatorList.Contains(dest.ServerURI) && !_failedSims.TryGetValue(dest.ServerURI, out v)) { // we havent seen this simulator before, add it to the list // and send it an update simulatorList.Add(dest.ServerURI); + // Let move this to sync. Mono definitely does not like async networking. + if (!m_scene.SimulationService.UpdateAgent(dest, cAgentData)) + // Also if it fails, get it out of the loop for a bit + _failedSims.Add(dest.ServerURI, true, 120); - SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; - d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, dest, - SendChildAgentDataUpdateCompleted, - d); + // Leaving this here as a reminder that we tried, and it sucks. + //SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; + //d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, dest, + // SendChildAgentDataUpdateCompleted, + // d); } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 77f7b32fe3..8639697f23 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2738,7 +2738,8 @@ namespace OpenSim.Region.Framework.Scenes AgentPosition agentpos = new AgentPosition(); agentpos.CopyFrom(cadu); - m_scene.SendOutChildAgentUpdates(agentpos, this); + // Let's get this out of the update loop + Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); }); } }