From cb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 6 Oct 2008 19:52:54 +0000 Subject: * Stop the sim stats reporter reusing the same SimStatsPacket for all clients * I believe this was the cause of the remaining packet_out_of_order messages in the Linden client logs * There were race conditions where multiple clientstacks would overwrite each other's sequence numbers --- .../Environment/Modules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Region/Environment/Scenes/Scene.cs | 4 +- .../Region/Environment/Scenes/SimStatsReporter.cs | 44 ++++++++++------------ 3 files changed, 23 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index a236ccd..b59b013 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -706,7 +706,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC { } - public void SendSimStats(Packet pack) + public void SendSimStats(SimStats stats) { } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bf1dbcd..da6da1e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -837,14 +837,14 @@ namespace OpenSim.Region.Environment.Scenes } } - private void SendSimStatsPackets(SimStatsPacket pack) + private void SendSimStatsPackets(SimStats stats) { List StatSendAgents = GetScenePresences(); foreach (ScenePresence agent in StatSendAgents) { if (!agent.IsChildAgent) { - agent.ControllingClient.SendSimStats(pack); + agent.ControllingClient.SendSimStats(stats); } } } diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 5f0f316..4c9c59d 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -36,7 +36,7 @@ namespace OpenSim.Region.Environment.Scenes { public class SimStatsReporter { - public delegate void SendStatResult(SimStatsPacket pack); + public delegate void SendStatResult(SimStats stats); public event SendStatResult OnSendStatsResult; @@ -100,12 +100,6 @@ namespace OpenSim.Region.Environment.Scenes private int objectCapacity = 45000; - - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; - SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); - SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats); - - private Scene m_scene; private RegionInfo ReportingRegion; @@ -118,10 +112,7 @@ namespace OpenSim.Region.Environment.Scenes statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); m_scene = scene; ReportingRegion = scene.RegionInfo; - for (int i = 0; i<21;i++) - { - sb[i] = new SimStatsPacket.StatBlock(); - } + m_report.AutoReset = true; m_report.Interval = statsUpdatesEveryMS; m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); @@ -140,26 +131,24 @@ namespace OpenSim.Region.Environment.Scenes private void statsHeartBeat(object sender, EventArgs e) { + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; + SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); + // Know what's not thread safe in Mono... modifying timers. // System.Console.WriteLine("Firing Stats Heart Beat"); lock (m_report) { - // Packet is already initialized and ready for data insert - - - statpack.Region = rb; - statpack.Region.RegionX = ReportingRegion.RegionLocX; - statpack.Region.RegionY = ReportingRegion.RegionLocY; + uint regionFlags = 0; + try { IEstateModule estateModule = m_scene.RequestModuleInterface(); - statpack.Region.RegionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0; + regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0; } catch (Exception) { - statpack.Region.RegionFlags = (uint) 0; + // leave region flags at 0 } - statpack.Region.ObjectCapacity = (uint) objectCapacity; #region various statistic googly moogly @@ -182,7 +171,7 @@ namespace OpenSim.Region.Environment.Scenes physfps = 0; #endregion - + //Our time dilation is 0.91 when we're running a full speed, // therefore to make sure we get an appropriate range, // we have to factor in our error. (0.10f * statsUpdateFactor) @@ -190,6 +179,11 @@ namespace OpenSim.Region.Environment.Scenes // / 10 divides the value by the number of times the sim heartbeat runs (10fps) // Then we divide the whole amount by the amount of seconds pass in between stats updates. + for (int i = 0; i<21;i++) + { + sb[i] = new SimStatsPacket.StatBlock(); + } + sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); @@ -252,13 +246,15 @@ namespace OpenSim.Region.Environment.Scenes sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; - - statpack.Stat = sb; + + SimStats simStats + = new SimStats( + ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb); handlerSendStatResult = OnSendStatsResult; if (handlerSendStatResult != null) { - handlerSendStatResult(statpack); + handlerSendStatResult(simStats); } resetvalues(); } -- cgit v1.1