From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../LoadRegions/LoadRegionsPlugin.cs | 2 +- .../LoadRegions/Properties/AssemblyInfo.cs | 3 +- .../LoadRegions/RegionLoaderFileSystem.cs | 25 ++--- .../LoadRegions/RegionLoaderWebServer.cs | 106 ++++++++++----------- 4 files changed, 62 insertions(+), 74 deletions(-) (limited to 'OpenSim/ApplicationPlugins/LoadRegions') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 89224a6..feb73a9 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -124,7 +124,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + ")"); - + bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); m_openSim.CreateRegion(regionsToLoad[i], true, out scene); diff --git a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs index 6c3c3e3..6b1ea73 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs @@ -61,9 +61,8 @@ using Mono.Addins; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("0.7.6.*")] -[assembly : AssemblyVersion("0.8.2.*")] +[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] [assembly: Addin("OpenSim.ApplicationPlugins.LoadRegions", OpenSim.VersionInfo.VersionNumber)] [assembly: AddinDependency("OpenSim", OpenSim.VersionInfo.VersionNumber)] diff --git a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs index ea95696..976714c 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs @@ -48,7 +48,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public RegionInfo[] LoadRegions() { - string regionConfigPath = Util.configDir(); + string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); bool allowRegionless = false; try @@ -68,14 +68,13 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); -//// Causes hangs with the actual .ini files if they are in the same place. -//// string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); + string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); // Create an empty Regions.ini if there are no existing config files. - if (!allowRegionless && configFiles.Length == 0 /*&& iniFiles.Length == 0*/) + if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0) { new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); -//// iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); + iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); } m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); @@ -83,7 +82,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions List regionInfos = new List(); int i = 0; -/* foreach (string file in iniFiles) { m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); @@ -100,22 +98,17 @@ namespace OpenSim.ApplicationPlugins.LoadRegions i++; } } -*/ + foreach (string file in configFiles) { m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); - IConfigSource source = new XmlConfigSource(file); - - foreach (IConfig config in source.Configs) - { - RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); - regionInfos.Add(regionInfo); + RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource); + regionInfos.Add(regionInfo); - m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); - i++; - } + i++; } return regionInfos.ToArray(); diff --git a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs index 850f3e0..2b91fc5 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs @@ -49,6 +49,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public RegionInfo[] LoadRegions() { + int tries = 3; + int wait = 2000; + if (m_configSource == null) { m_log.Error("[WEBLOADER]: Unable to load configuration source!"); @@ -56,7 +59,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } else { - IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; + IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false); @@ -67,82 +70,75 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } else { - RegionInfo[] regionInfos = new RegionInfo[] {}; - int regionCount = 0; - HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); - webRequest.Timeout = 30000; //30 Second Timeout - m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); - - try + while (tries > 0) { - string xmlSource = String.Empty; + RegionInfo[] regionInfos = new RegionInfo[] { }; + int regionCount = 0; + HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); + webRequest.Timeout = 30000; //30 Second Timeout + m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); - using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse()) + try { + HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); m_log.Debug("[WEBLOADER]: Downloading region information..."); - - using (Stream s = webResponse.GetResponseStream()) + StreamReader reader = new StreamReader(webResponse.GetResponseStream()); + string xmlSource = String.Empty; + string tempStr = reader.ReadLine(); + while (tempStr != null) { - using (StreamReader reader = new StreamReader(s)) - { - string tempStr = reader.ReadLine(); - while (tempStr != null) - { - xmlSource = xmlSource + tempStr; - tempStr = reader.ReadLine(); - } - } + xmlSource = xmlSource + tempStr; + tempStr = reader.ReadLine(); } - } - - m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + - xmlSource.Length); - XmlDocument xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(xmlSource); - if (xmlDoc.FirstChild.Name == "Nini") - { - regionCount = xmlDoc.FirstChild.ChildNodes.Count; - - if (regionCount > 0) + m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + + xmlSource.Length); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.XmlResolver = null; + xmlDoc.LoadXml(xmlSource); + if (xmlDoc.FirstChild.Name == "Nini") { - regionInfos = new RegionInfo[regionCount]; - int i; - for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) + regionCount = xmlDoc.FirstChild.ChildNodes.Count; + + if (regionCount > 0) { - m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); - regionInfos[i] = - new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); + regionInfos = new RegionInfo[regionCount]; + int i; + for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) + { + m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); + regionInfos[i] = + new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i], false, m_configSource); + } } } } - } - catch (WebException ex) - { - using (HttpWebResponse response = (HttpWebResponse)ex.Response) + catch (WebException ex) { - if (response.StatusCode == HttpStatusCode.NotFound) + if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) { if (!allowRegionless) throw ex; } else - { throw ex; - } } - } - if (regionCount > 0 | allowRegionless) - { - return regionInfos; - } - else - { - m_log.Error("[WEBLOADER]: No region configs were available."); - return null; + if (regionCount > 0 | allowRegionless) + return regionInfos; + + m_log.Debug("[WEBLOADER]: Request yielded no regions."); + tries--; + if (tries > 0) + { + m_log.Debug("[WEBLOADER]: Retrying"); + System.Threading.Thread.Sleep(wait); + } } + + m_log.Error("[WEBLOADER]: No region configs were available."); + return null; } } } } -} +} \ No newline at end of file -- cgit v1.1