diff options
Diffstat (limited to 'OpenSim/Region/DataSnapshot/DataSnapshotManager.cs')
-rw-r--r-- | OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 3f934c9..782b431 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | |||
@@ -32,7 +32,6 @@ using System.IO; | |||
32 | using System.Net; | 32 | using System.Net; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Text; | 34 | using System.Text; |
35 | using System.Timers; | ||
36 | using System.Xml; | 35 | using System.Xml; |
37 | using OpenMetaverse; | 36 | using OpenMetaverse; |
38 | using log4net; | 37 | using log4net; |
@@ -71,12 +70,10 @@ namespace OpenSim.Region.DataSnapshot | |||
71 | public string m_hostname = "127.0.0.1"; | 70 | public string m_hostname = "127.0.0.1"; |
72 | 71 | ||
73 | //Update timers | 72 | //Update timers |
74 | private Timer m_periodic = null; | ||
75 | private int m_period = 20; // in seconds | 73 | private int m_period = 20; // in seconds |
76 | private int m_maxStales = 500; | 74 | private int m_maxStales = 500; |
77 | private int m_stales = 0; | 75 | private int m_stales = 0; |
78 | private Timer m_passedCheck = null; | 76 | private int m_lastUpdate = 0; |
79 | private bool m_periodPassed = false; | ||
80 | 77 | ||
81 | //Program objects | 78 | //Program objects |
82 | private SnapshotStore m_snapStore = null; | 79 | private SnapshotStore m_snapStore = null; |
@@ -126,6 +123,7 @@ namespace OpenSim.Region.DataSnapshot | |||
126 | { | 123 | { |
127 | m_disabledModules.Add(bloody_wanker); | 124 | m_disabledModules.Add(bloody_wanker); |
128 | } | 125 | } |
126 | m_lastUpdate = System.Environment.TickCount; | ||
129 | } | 127 | } |
130 | catch (Exception) | 128 | catch (Exception) |
131 | { | 129 | { |
@@ -137,17 +135,6 @@ namespace OpenSim.Region.DataSnapshot | |||
137 | 135 | ||
138 | if (m_enabled) | 136 | if (m_enabled) |
139 | { | 137 | { |
140 | //Create update timer | ||
141 | m_periodic = new Timer(); | ||
142 | m_periodic.Interval = m_period * 1000; | ||
143 | m_periodic.Elapsed += SnapshotTimerCallback; | ||
144 | |||
145 | //Create update eligibility timer | ||
146 | m_passedCheck = new Timer(); | ||
147 | m_passedCheck.Interval = m_period * 1000; | ||
148 | m_passedCheck.Elapsed += UpdateEligibilityCallback; | ||
149 | m_passedCheck.Start(); | ||
150 | |||
151 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | 138 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer |
152 | new DataRequestHandler(scene, this); | 139 | new DataRequestHandler(scene, this); |
153 | 140 | ||
@@ -253,6 +240,8 @@ namespace OpenSim.Region.DataSnapshot | |||
253 | */ | 240 | */ |
254 | public XmlDocument GetSnapshot(string regionName) | 241 | public XmlDocument GetSnapshot(string regionName) |
255 | { | 242 | { |
243 | CheckStale(); | ||
244 | |||
256 | XmlDocument requestedSnap = new XmlDocument(); | 245 | XmlDocument requestedSnap = new XmlDocument(); |
257 | requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null)); | 246 | requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null)); |
258 | requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n")); | 247 | requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n")); |
@@ -369,38 +358,34 @@ namespace OpenSim.Region.DataSnapshot | |||
369 | //Behavior here: Wait m_period seconds, then update if there has not been a request in m_period seconds | 358 | //Behavior here: Wait m_period seconds, then update if there has not been a request in m_period seconds |
370 | //or m_maxStales has been exceeded | 359 | //or m_maxStales has been exceeded |
371 | m_stales++; | 360 | m_stales++; |
372 | |||
373 | if ((m_stales >= m_maxStales) && m_periodPassed) | ||
374 | SnapshotTimerCallback(m_periodic, null); | ||
375 | else if (m_periodic.Enabled == false) | ||
376 | m_periodic.Start(); | ||
377 | else | ||
378 | { | ||
379 | m_periodic.Stop(); | ||
380 | m_periodic.Start(); | ||
381 | } | ||
382 | } | 361 | } |
383 | 362 | ||
384 | private void SnapshotTimerCallback(object timer, ElapsedEventArgs args) | 363 | private void CheckStale() |
385 | { | 364 | { |
386 | m_log.Debug("[DATASNAPSHOT]: Marking scenes for snapshot updates."); | 365 | // Wrap check |
387 | 366 | if (System.Environment.TickCount < m_lastUpdate) | |
388 | //Finally generate those snapshot updates | 367 | { |
389 | MakeEverythingStale(); | 368 | m_lastUpdate = System.Environment.TickCount; |
390 | 369 | } | |
391 | //Stop the update delay timer | ||
392 | m_periodic.Stop(); | ||
393 | |||
394 | //Reset the eligibility flag and timer | ||
395 | m_periodPassed = false; | ||
396 | m_passedCheck.Stop(); | ||
397 | m_passedCheck.Start(); | ||
398 | } | ||
399 | 370 | ||
400 | private void UpdateEligibilityCallback(object timer, ElapsedEventArgs args) | 371 | if (m_stales >= m_maxStales) |
401 | { | 372 | { |
402 | //Set eligibility, so we can start making updates | 373 | if (System.Environment.TickCount - m_lastUpdate >= 20000) |
403 | m_periodPassed = true; | 374 | { |
375 | m_stales = 0; | ||
376 | m_lastUpdate = System.Environment.TickCount; | ||
377 | MakeEverythingStale(); | ||
378 | } | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | if (m_lastUpdate + 1000 * m_period < System.Environment.TickCount) | ||
383 | { | ||
384 | m_stales = 0; | ||
385 | m_lastUpdate = System.Environment.TickCount; | ||
386 | MakeEverythingStale(); | ||
387 | } | ||
388 | } | ||
404 | } | 389 | } |
405 | 390 | ||
406 | public void MakeEverythingStale() | 391 | public void MakeEverythingStale() |