aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-06 19:52:54 +0000
committerJustin Clarke Casey2008-10-06 19:52:54 +0000
commitcb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a (patch)
treef4f8c4f3b849f35e4a4e56d05740ad19651d4a71
parentcleaning up OSHttpRequest removing old Http stuff. also adding test (diff)
downloadopensim-SC_OLD-cb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a.zip
opensim-SC_OLD-cb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a.tar.gz
opensim-SC_OLD-cb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a.tar.bz2
opensim-SC_OLD-cb7a9eaa09fba301ba6b6838cb9e3cedfc29a32a.tar.xz
* 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
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IClientAPI.cs8
-rw-r--r--OpenSim/Framework/SimStats.cs88
-rw-r--r--OpenSim/Framework/Statistics/SimExtraStatsCollector.cs48
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/SimStatsReporter.cs44
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
8 files changed, 155 insertions, 55 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 1a6a5a4..4071e47 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -722,7 +722,13 @@ namespace OpenSim.Framework
722 void SendImagePart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec); 722 void SendImagePart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec);
723 723
724 void SendShutdownConnectionNotice(); 724 void SendShutdownConnectionNotice();
725 void SendSimStats(Packet pack); 725
726 /// <summary>
727 /// Send statistical information about the sim to the client.
728 /// </summary>
729 /// <param name="stats"></param>
730 void SendSimStats(SimStats stats);
731
726 void SendObjectPropertiesFamilyData(uint RequestFlags, UUID ObjectUUID, UUID OwnerID, UUID GroupID, 732 void SendObjectPropertiesFamilyData(uint RequestFlags, UUID ObjectUUID, UUID OwnerID, UUID GroupID,
727 uint BaseMask, uint OwnerMask, uint GroupMask, uint EveryoneMask, 733 uint BaseMask, uint OwnerMask, uint GroupMask, uint EveryoneMask,
728 uint NextOwnerMask, int OwnershipCost, byte SaleType, int SalePrice, uint Category, 734 uint NextOwnerMask, int OwnershipCost, byte SaleType, int SalePrice, uint Category,
diff --git a/OpenSim/Framework/SimStats.cs b/OpenSim/Framework/SimStats.cs
new file mode 100644
index 0000000..c77d0d4
--- /dev/null
+++ b/OpenSim/Framework/SimStats.cs
@@ -0,0 +1,88 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse.Packets;
29
30namespace OpenSim.Framework
31{
32 /// <summary>
33 /// Enapsulate statistics for a simulator/scene.
34 ///
35 /// TODO: This looks very much like the OpenMetaverse SimStatsPacket. It should be much more generic stats
36 /// storage.
37 /// </summary>
38 public class SimStats
39 {
40 public uint RegionX
41 {
42 get { return m_regionX; }
43 }
44 private uint m_regionX;
45
46 public uint RegionY
47 {
48 get { return m_regionY; }
49 }
50 private uint m_regionY;
51
52 public SimStatsPacket.RegionBlock RegionBlock
53 {
54 get { return m_regionBlock; }
55 }
56 private SimStatsPacket.RegionBlock m_regionBlock;
57
58 public SimStatsPacket.StatBlock[] StatsBlock
59 {
60 get { return m_statsBlock; }
61 }
62 private SimStatsPacket.StatBlock[] m_statsBlock;
63
64 public uint RegionFlags
65 {
66 get { return m_regionFlags; }
67 }
68 private uint m_regionFlags;
69
70 public uint ObjectCapacity
71 {
72 get { return m_objectCapacity; }
73 }
74 private uint m_objectCapacity;
75
76 public SimStats(
77 uint regionX, uint regionY, uint regionFlags, uint objectCapacity,
78 SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock)
79 {
80 m_regionX = regionX;
81 m_regionY = regionY;
82 m_regionFlags = regionFlags;
83 m_objectCapacity = objectCapacity;
84 m_regionBlock = regionBlock;
85 m_statsBlock = statsBlock;
86 }
87 }
88}
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
index 2f6bb7e..48bed81 100644
--- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
@@ -216,31 +216,31 @@ namespace OpenSim.Framework.Statistics
216 /// client purposes) sends information to listeners. 216 /// client purposes) sends information to listeners.
217 /// </summary> 217 /// </summary>
218 /// <param name="pack"></param> 218 /// <param name="pack"></param>
219 public void ReceiveClassicSimStatsPacket(SimStatsPacket statsPacket) 219 public void ReceiveClassicSimStatsPacket(SimStats stats)
220 { 220 {
221 // FIXME: Really shouldn't rely on the probably arbitrary order in which 221 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
222 // stats are packed into the packet 222 // SimStatsPacket that was being used).
223 timeDilation = statsPacket.Stat[0].StatValue; 223 timeDilation = stats.StatsBlock[0].StatValue;
224 simFps = statsPacket.Stat[1].StatValue; 224 simFps = stats.StatsBlock[1].StatValue;
225 physicsFps = statsPacket.Stat[2].StatValue; 225 physicsFps = stats.StatsBlock[2].StatValue;
226 agentUpdates = statsPacket.Stat[3].StatValue; 226 agentUpdates = stats.StatsBlock[3].StatValue;
227 rootAgents = statsPacket.Stat[4].StatValue; 227 rootAgents = stats.StatsBlock[4].StatValue;
228 childAgents = statsPacket.Stat[5].StatValue; 228 childAgents = stats.StatsBlock[5].StatValue;
229 totalPrims = statsPacket.Stat[6].StatValue; 229 totalPrims = stats.StatsBlock[6].StatValue;
230 activePrims = statsPacket.Stat[7].StatValue; 230 activePrims = stats.StatsBlock[7].StatValue;
231 totalFrameTime = statsPacket.Stat[8].StatValue; 231 totalFrameTime = stats.StatsBlock[8].StatValue;
232 netFrameTime = statsPacket.Stat[9].StatValue; 232 netFrameTime = stats.StatsBlock[9].StatValue;
233 physicsFrameTime = statsPacket.Stat[10].StatValue; 233 physicsFrameTime = stats.StatsBlock[10].StatValue;
234 otherFrameTime = statsPacket.Stat[11].StatValue; 234 otherFrameTime = stats.StatsBlock[11].StatValue;
235 imageFrameTime = statsPacket.Stat[12].StatValue; 235 imageFrameTime = stats.StatsBlock[12].StatValue;
236 inPacketsPerSecond = statsPacket.Stat[13].StatValue; 236 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
237 outPacketsPerSecond = statsPacket.Stat[14].StatValue; 237 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
238 unackedBytes = statsPacket.Stat[15].StatValue; 238 unackedBytes = stats.StatsBlock[15].StatValue;
239 agentFrameTime = statsPacket.Stat[16].StatValue; 239 agentFrameTime = stats.StatsBlock[16].StatValue;
240 pendingDownloads = statsPacket.Stat[17].StatValue; 240 pendingDownloads = stats.StatsBlock[17].StatValue;
241 pendingUploads = statsPacket.Stat[18].StatValue; 241 pendingUploads = stats.StatsBlock[18].StatValue;
242 activeScripts = statsPacket.Stat[19].StatValue; 242 activeScripts = stats.StatsBlock[19].StatValue;
243 scriptLinesPerSecond = statsPacket.Stat[20].StatValue; 243 scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
244 } 244 }
245 245
246 /// <summary> 246 /// <summary>
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index ff35c32..cbba661 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -2610,9 +2610,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2610 OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown); 2610 OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
2611 } 2611 }
2612 2612
2613 public void SendSimStats(Packet pack) 2613 public void SendSimStats(SimStats stats)
2614 { 2614 {
2615 SimStatsPacket pack = new SimStatsPacket();
2616
2617 pack.Region.RegionX = stats.RegionX;
2618 pack.Region.RegionY = stats.RegionY;
2619 pack.Region.RegionFlags = stats.RegionFlags;
2620 pack.Region.ObjectCapacity = stats.ObjectCapacity;
2621 pack.Region = stats.RegionBlock;
2622 pack.Stat = stats.StatsBlock;
2623
2615 pack.Header.Reliable = false; 2624 pack.Header.Reliable = false;
2625
2616 OutPacket(pack, ThrottleOutPacketType.Task); 2626 OutPacket(pack, ThrottleOutPacketType.Task);
2617 } 2627 }
2618 2628
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
706 { 706 {
707 } 707 }
708 708
709 public void SendSimStats(Packet pack) 709 public void SendSimStats(SimStats stats)
710 { 710 {
711 } 711 }
712 712
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
837 } 837 }
838 } 838 }
839 839
840 private void SendSimStatsPackets(SimStatsPacket pack) 840 private void SendSimStatsPackets(SimStats stats)
841 { 841 {
842 List<ScenePresence> StatSendAgents = GetScenePresences(); 842 List<ScenePresence> StatSendAgents = GetScenePresences();
843 foreach (ScenePresence agent in StatSendAgents) 843 foreach (ScenePresence agent in StatSendAgents)
844 { 844 {
845 if (!agent.IsChildAgent) 845 if (!agent.IsChildAgent)
846 { 846 {
847 agent.ControllingClient.SendSimStats(pack); 847 agent.ControllingClient.SendSimStats(stats);
848 } 848 }
849 } 849 }
850 } 850 }
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
36{ 36{
37 public class SimStatsReporter 37 public class SimStatsReporter
38 { 38 {
39 public delegate void SendStatResult(SimStatsPacket pack); 39 public delegate void SendStatResult(SimStats stats);
40 40
41 public event SendStatResult OnSendStatsResult; 41 public event SendStatResult OnSendStatsResult;
42 42
@@ -100,12 +100,6 @@ namespace OpenSim.Region.Environment.Scenes
100 100
101 private int objectCapacity = 45000; 101 private int objectCapacity = 45000;
102 102
103
104 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
105 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
106 SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats);
107
108
109 private Scene m_scene; 103 private Scene m_scene;
110 104
111 private RegionInfo ReportingRegion; 105 private RegionInfo ReportingRegion;
@@ -118,10 +112,7 @@ namespace OpenSim.Region.Environment.Scenes
118 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 112 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
119 m_scene = scene; 113 m_scene = scene;
120 ReportingRegion = scene.RegionInfo; 114 ReportingRegion = scene.RegionInfo;
121 for (int i = 0; i<21;i++) 115
122 {
123 sb[i] = new SimStatsPacket.StatBlock();
124 }
125 m_report.AutoReset = true; 116 m_report.AutoReset = true;
126 m_report.Interval = statsUpdatesEveryMS; 117 m_report.Interval = statsUpdatesEveryMS;
127 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); 118 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
@@ -140,26 +131,24 @@ namespace OpenSim.Region.Environment.Scenes
140 131
141 private void statsHeartBeat(object sender, EventArgs e) 132 private void statsHeartBeat(object sender, EventArgs e)
142 { 133 {
134 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
135 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
136
143 // Know what's not thread safe in Mono... modifying timers. 137 // Know what's not thread safe in Mono... modifying timers.
144 // System.Console.WriteLine("Firing Stats Heart Beat"); 138 // System.Console.WriteLine("Firing Stats Heart Beat");
145 lock (m_report) 139 lock (m_report)
146 { 140 {
147 // Packet is already initialized and ready for data insert 141 uint regionFlags = 0;
148 142
149
150 statpack.Region = rb;
151 statpack.Region.RegionX = ReportingRegion.RegionLocX;
152 statpack.Region.RegionY = ReportingRegion.RegionLocY;
153 try 143 try
154 { 144 {
155 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); 145 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>();
156 statpack.Region.RegionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0; 146 regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
157 } 147 }
158 catch (Exception) 148 catch (Exception)
159 { 149 {
160 statpack.Region.RegionFlags = (uint) 0; 150 // leave region flags at 0
161 } 151 }
162 statpack.Region.ObjectCapacity = (uint) objectCapacity;
163 152
164#region various statistic googly moogly 153#region various statistic googly moogly
165 154
@@ -182,7 +171,7 @@ namespace OpenSim.Region.Environment.Scenes
182 physfps = 0; 171 physfps = 0;
183 172
184#endregion 173#endregion
185 174
186 //Our time dilation is 0.91 when we're running a full speed, 175 //Our time dilation is 0.91 when we're running a full speed,
187 // therefore to make sure we get an appropriate range, 176 // therefore to make sure we get an appropriate range,
188 // we have to factor in our error. (0.10f * statsUpdateFactor) 177 // we have to factor in our error. (0.10f * statsUpdateFactor)
@@ -190,6 +179,11 @@ namespace OpenSim.Region.Environment.Scenes
190 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 179 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
191 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 180 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
192 181
182 for (int i = 0; i<21;i++)
183 {
184 sb[i] = new SimStatsPacket.StatBlock();
185 }
186
193 sb[0].StatID = (uint) Stats.TimeDilation; 187 sb[0].StatID = (uint) Stats.TimeDilation;
194 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 188 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
195 189
@@ -252,13 +246,15 @@ namespace OpenSim.Region.Environment.Scenes
252 246
253 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 247 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
254 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 248 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
255 249
256 statpack.Stat = sb; 250 SimStats simStats
251 = new SimStats(
252 ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb);
257 253
258 handlerSendStatResult = OnSendStatsResult; 254 handlerSendStatResult = OnSendStatsResult;
259 if (handlerSendStatResult != null) 255 if (handlerSendStatResult != null)
260 { 256 {
261 handlerSendStatResult(statpack); 257 handlerSendStatResult(simStats);
262 } 258 }
263 resetvalues(); 259 resetvalues();
264 } 260 }
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 9c8152d..87478c7 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -625,7 +625,7 @@ namespace OpenSim.Region.Examples.SimpleModule
625 { 625 {
626 } 626 }
627 627
628 public void SendSimStats(Packet pack) 628 public void SendSimStats(SimStats stats)
629 { 629 {
630 } 630 }
631 631