aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/WebStatsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs45
1 files changed, 31 insertions, 14 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index b08233c..64cb577 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -94,8 +94,6 @@ namespace OpenSim.Region.UserStatistics
94 if (!enabled) 94 if (!enabled)
95 return; 95 return;
96 96
97 AddEventHandlers();
98
99 if (Util.IsWindows()) 97 if (Util.IsWindows())
100 Util.LoadArchSpecificWindowsDll("sqlite3.dll"); 98 Util.LoadArchSpecificWindowsDll("sqlite3.dll");
101 99
@@ -143,10 +141,14 @@ namespace OpenSim.Region.UserStatistics
143 lock (m_scenes) 141 lock (m_scenes)
144 { 142 {
145 m_scenes.Add(scene); 143 m_scenes.Add(scene);
146 if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) 144 updateLogMod = m_scenes.Count * 2;
147 m_simstatsCounters.Remove(scene.RegionInfo.RegionID);
148 145
149 m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID)); 146 m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID));
147
148 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
149 scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps;
150 scene.EventManager.OnClientClosed += OnClientClosed;
151 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
150 scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket; 152 scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket;
151 } 153 }
152 } 154 }
@@ -157,6 +159,15 @@ namespace OpenSim.Region.UserStatistics
157 159
158 public void RemoveRegion(Scene scene) 160 public void RemoveRegion(Scene scene)
159 { 161 {
162 if (!enabled)
163 return;
164
165 lock (m_scenes)
166 {
167 m_scenes.Remove(scene);
168 updateLogMod = m_scenes.Count * 2;
169 m_simstatsCounters.Remove(scene.RegionInfo.RegionID);
170 }
160 } 171 }
161 172
162 public virtual void Close() 173 public virtual void Close()
@@ -187,9 +198,7 @@ namespace OpenSim.Region.UserStatistics
187 private void ReceiveClassicSimStatsPacket(SimStats stats) 198 private void ReceiveClassicSimStatsPacket(SimStats stats)
188 { 199 {
189 if (!enabled) 200 if (!enabled)
190 {
191 return; 201 return;
192 }
193 202
194 try 203 try
195 { 204 {
@@ -198,17 +207,25 @@ namespace OpenSim.Region.UserStatistics
198 if (concurrencyCounter > 0 || System.Environment.TickCount - lastHit > 30000) 207 if (concurrencyCounter > 0 || System.Environment.TickCount - lastHit > 30000)
199 return; 208 return;
200 209
201 if ((updateLogCounter++ % updateLogMod) == 0) 210 // We will conduct this under lock so that fields such as updateLogCounter do not potentially get
211 // confused if a scene is removed.
212 // XXX: Possibly the scope of this lock could be reduced though it's not critical.
213 lock (m_scenes)
202 { 214 {
203 m_loglines = readLogLines(10); 215 if (updateLogMod != 0 && updateLogCounter++ % updateLogMod == 0)
204 if (updateLogCounter > 10000) updateLogCounter = 1; 216 {
205 } 217 m_loglines = readLogLines(10);
206 218
207 USimStatsData ss = m_simstatsCounters[stats.RegionUUID]; 219 if (updateLogCounter > 10000)
220 updateLogCounter = 1;
221 }
208 222
209 if ((++ss.StatsCounter % updateStatsMod) == 0) 223 USimStatsData ss = m_simstatsCounters[stats.RegionUUID];
210 { 224
211 ss.ConsumeSimStats(stats); 225 if ((++ss.StatsCounter % updateStatsMod) == 0)
226 {
227 ss.ConsumeSimStats(stats);
228 }
212 } 229 }
213 } 230 }
214 catch (KeyNotFoundException) 231 catch (KeyNotFoundException)