throtle datasnapshot gen

httptests
UbitUmarov 2018-01-22 18:37:39 +00:00
parent e3fc272f50
commit efc7480342
2 changed files with 22 additions and 5 deletions

View File

@ -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;
}

View File

@ -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)