Make webloading more robust by addign retries
parent
85f454e3ae
commit
e06b7ee368
|
@ -48,6 +48,9 @@ namespace OpenSim.Framework.RegionLoader.Web
|
||||||
|
|
||||||
public RegionInfo[] LoadRegions()
|
public RegionInfo[] LoadRegions()
|
||||||
{
|
{
|
||||||
|
int tries = 3;
|
||||||
|
int wait = 2000;
|
||||||
|
|
||||||
if (m_configSource == null)
|
if (m_configSource == null)
|
||||||
{
|
{
|
||||||
m_log.Error("[WEBLOADER]: Unable to load configuration source!");
|
m_log.Error("[WEBLOADER]: Unable to load configuration source!");
|
||||||
|
@ -64,35 +67,28 @@ namespace OpenSim.Framework.RegionLoader.Web
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
|
while (tries > 0)
|
||||||
webRequest.Timeout = 30000; //30 Second Timeout
|
|
||||||
m_log.Debug("[WEBLOADER]: Sending Download Request...");
|
|
||||||
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
|
|
||||||
m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server...");
|
|
||||||
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
|
|
||||||
string xmlSource = String.Empty;
|
|
||||||
string tempStr = reader.ReadLine();
|
|
||||||
while (tempStr != null)
|
|
||||||
{
|
{
|
||||||
xmlSource = xmlSource + tempStr;
|
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
|
||||||
tempStr = reader.ReadLine();
|
webRequest.Timeout = 30000; //30 Second Timeout
|
||||||
}
|
m_log.Debug("[WEBLOADER]: Sending Download Request...");
|
||||||
m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
|
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
|
||||||
xmlSource.Length);
|
m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server...");
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
|
||||||
xmlDoc.LoadXml(xmlSource);
|
string xmlSource = String.Empty;
|
||||||
if (xmlDoc.FirstChild.Name == "Regions")
|
string tempStr = reader.ReadLine();
|
||||||
{
|
while (tempStr != null)
|
||||||
RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count];
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
|
|
||||||
{
|
{
|
||||||
m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
|
xmlSource = xmlSource + tempStr;
|
||||||
regionInfos[i] =
|
tempStr = reader.ReadLine();
|
||||||
new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
|
}
|
||||||
|
m_log.Debug("[WEBLOADER]: Request yielded no regions.");
|
||||||
|
tries--;
|
||||||
|
if (tries > 0)
|
||||||
|
{
|
||||||
|
m_log.Debug("[WEBLOADER]: Retrying");
|
||||||
|
System.Threading.Thread.Sleep(wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
return regionInfos;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue