From efc74803424a5e12ce780ecdd839d144123ae79e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Jan 2018 18:37:39 +0000 Subject: [PATCH] throtle datasnapshot gen --- .../DataSnapshot/DataRequestHandler.cs | 14 ++++++++++---- .../DataSnapshot/DataSnapshotManager.cs | 13 ++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs index 5a01fa9765..fb60e9e8a0 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs @@ -63,18 +63,24 @@ namespace OpenSim.Region.DataSnapshot public Hashtable OnGetSnapshot(Hashtable keysvals) { - m_log.Debug("[DATASNAPSHOT] Received collection request"); + string snapObj = (string)keysvals["region"]; + m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj); Hashtable reply = new Hashtable(); int statuscode = 200; - string snapObj = (string)keysvals["region"]; - XmlDocument response = m_externalData.GetSnapshot(snapObj); + if(response == null) + { + reply["str_response_string"] = string.Empty; + reply["int_response_code"] = 503; + reply["content_type"] = "text"; + m_log.Debug("[DATASNAPSHOT] Collection request reply try later"); + return reply; + } reply["str_response_string"] = response.OuterXml; reply["int_response_code"] = statuscode; reply["content_type"] = "text/xml"; - return reply; } diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs index 0436f96a28..88fa1ae0b6 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs @@ -32,6 +32,7 @@ using System.IO; using System.Linq; using System.Net; using System.Reflection; +using System.Threading; using System.Text; using System.Xml; using log4net; @@ -64,6 +65,7 @@ namespace OpenSim.Region.DataSnapshot //Various internal objects private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); internal object m_syncInit = new object(); + private object m_serializeGen = new object(); //DataServices and networking private string m_dataServices = "noservices"; @@ -321,6 +323,11 @@ namespace OpenSim.Region.DataSnapshot */ public XmlDocument GetSnapshot(string regionName) { + if(!Monitor.TryEnter(m_serializeGen,30000)) + { + return null; + } + CheckStale(); XmlDocument requestedSnap = new XmlDocument(); @@ -360,9 +367,13 @@ namespace OpenSim.Region.DataSnapshot m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); requestedSnap = GetErrorMessage(regionName, e); } - + finally + { + Monitor.Exit(m_serializeGen); + } return requestedSnap; + } private XmlDocument GetErrorMessage(string regionName, Exception e)