aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs45
1 files changed, 26 insertions, 19 deletions
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
index 0436f96..fd841d4 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
@@ -32,6 +32,7 @@ using System.IO;
32using System.Linq; 32using System.Linq;
33using System.Net; 33using System.Net;
34using System.Reflection; 34using System.Reflection;
35using System.Threading;
35using System.Text; 36using System.Text;
36using System.Xml; 37using System.Xml;
37using log4net; 38using log4net;
@@ -64,6 +65,7 @@ namespace OpenSim.Region.DataSnapshot
64 //Various internal objects 65 //Various internal objects
65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 66 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66 internal object m_syncInit = new object(); 67 internal object m_syncInit = new object();
68 private object m_serializeGen = new object();
67 69
68 //DataServices and networking 70 //DataServices and networking
69 private string m_dataServices = "noservices"; 71 private string m_dataServices = "noservices";
@@ -148,11 +150,8 @@ namespace OpenSim.Region.DataSnapshot
148 m_enabled = false; 150 m_enabled = false;
149 return; 151 return;
150 } 152 }
151
152 } 153 }
153
154 } 154 }
155
156 } 155 }
157 156
158 public void AddRegion(Scene scene) 157 public void AddRegion(Scene scene)
@@ -160,23 +159,14 @@ namespace OpenSim.Region.DataSnapshot
160 if (!m_enabled) 159 if (!m_enabled)
161 return; 160 return;
162 161
163 m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); 162 m_scenes.Add(scene);
164 163
165 if (!m_servicesNotified) 164 if (m_snapStore == null)
166 { 165 {
167 m_hostname = scene.RegionInfo.ExternalHostName; 166 m_hostname = scene.RegionInfo.ExternalHostName;
168 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); 167 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname);
169
170 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer
171 new DataRequestHandler(scene, this);
172
173 if (m_dataServices != "" && m_dataServices != "noservices")
174 NotifyDataServices(m_dataServices, "online");
175
176 m_servicesNotified = true;
177 } 168 }
178 169
179 m_scenes.Add(scene);
180 m_snapStore.AddScene(scene); 170 m_snapStore.AddScene(scene);
181 171
182 Assembly currentasm = Assembly.GetExecutingAssembly(); 172 Assembly currentasm = Assembly.GetExecutingAssembly();
@@ -201,7 +191,7 @@ namespace OpenSim.Region.DataSnapshot
201 } 191 }
202 } 192 }
203 } 193 }
204 194 m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName);
205 } 195 }
206 196
207 public void RemoveRegion(Scene scene) 197 public void RemoveRegion(Scene scene)
@@ -244,8 +234,16 @@ namespace OpenSim.Region.DataSnapshot
244 if (!m_enabled) 234 if (!m_enabled)
245 return; 235 return;
246 236
247 m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); 237 if (!m_servicesNotified)
248 m_snapStore.ForceSceneStale(scene); 238 {
239 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer
240 new DataRequestHandler(scene, this);
241
242 if (m_dataServices != "" && m_dataServices != "noservices")
243 NotifyDataServices(m_dataServices, "online");
244
245 m_servicesNotified = true;
246 }
249 } 247 }
250 248
251 public void Close() 249 public void Close()
@@ -257,7 +255,6 @@ namespace OpenSim.Region.DataSnapshot
257 NotifyDataServices(m_dataServices, "offline"); 255 NotifyDataServices(m_dataServices, "offline");
258 } 256 }
259 257
260
261 public string Name 258 public string Name
262 { 259 {
263 get { return "External Data Generator"; } 260 get { return "External Data Generator"; }
@@ -319,8 +316,14 @@ namespace OpenSim.Region.DataSnapshot
319 /** 316 /**
320 * Reply to the http request 317 * Reply to the http request
321 */ 318 */
319
322 public XmlDocument GetSnapshot(string regionName) 320 public XmlDocument GetSnapshot(string regionName)
323 { 321 {
322 if(!Monitor.TryEnter(m_serializeGen,30000))
323 {
324 return null;
325 }
326
324 CheckStale(); 327 CheckStale();
325 328
326 XmlDocument requestedSnap = new XmlDocument(); 329 XmlDocument requestedSnap = new XmlDocument();
@@ -360,9 +363,13 @@ namespace OpenSim.Region.DataSnapshot
360 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); 363 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace);
361 requestedSnap = GetErrorMessage(regionName, e); 364 requestedSnap = GetErrorMessage(regionName, e);
362 } 365 }
363 366 finally
367 {
368 Monitor.Exit(m_serializeGen);
369 }
364 370
365 return requestedSnap; 371 return requestedSnap;
372
366 } 373 }
367 374
368 private XmlDocument GetErrorMessage(string regionName, Exception e) 375 private XmlDocument GetErrorMessage(string regionName, Exception e)