aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/LoadRegions
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/ApplicationPlugins/LoadRegions
parentAdd a build script. (diff)
downloadopensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/ApplicationPlugins/LoadRegions')
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs2
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs3
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs25
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs106
4 files changed, 62 insertions, 74 deletions
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
124 m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + 124 m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
125 Thread.CurrentThread.ManagedThreadId.ToString() + 125 Thread.CurrentThread.ManagedThreadId.ToString() +
126 ")"); 126 ")");
127 127
128 bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); 128 bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
129 129
130 m_openSim.CreateRegion(regionsToLoad[i], true, out scene); 130 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;
61// 61//
62// You can specify all the values or you can default the Build and Revision Numbers 62// You can specify all the values or you can default the Build and Revision Numbers
63// by using the '*' as shown below: 63// by using the '*' as shown below:
64// [assembly: AssemblyVersion("0.7.6.*")]
65 64
66[assembly : AssemblyVersion("0.8.2.*")] 65[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
67 66
68[assembly: Addin("OpenSim.ApplicationPlugins.LoadRegions", OpenSim.VersionInfo.VersionNumber)] 67[assembly: Addin("OpenSim.ApplicationPlugins.LoadRegions", OpenSim.VersionInfo.VersionNumber)]
69[assembly: AddinDependency("OpenSim", OpenSim.VersionInfo.VersionNumber)] 68[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
48 48
49 public RegionInfo[] LoadRegions() 49 public RegionInfo[] LoadRegions()
50 { 50 {
51 string regionConfigPath = Util.configDir(); 51 string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
52 bool allowRegionless = false; 52 bool allowRegionless = false;
53 53
54 try 54 try
@@ -68,14 +68,13 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
68 } 68 }
69 69
70 string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); 70 string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
71//// Causes hangs with the actual .ini files if they are in the same place. 71 string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
72//// string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
73 72
74 // Create an empty Regions.ini if there are no existing config files. 73 // Create an empty Regions.ini if there are no existing config files.
75 if (!allowRegionless && configFiles.Length == 0 /*&& iniFiles.Length == 0*/) 74 if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0)
76 { 75 {
77 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); 76 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource);
78//// iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); 77 iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
79 } 78 }
80 79
81 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); 80 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath);
@@ -83,7 +82,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
83 List<RegionInfo> regionInfos = new List<RegionInfo>(); 82 List<RegionInfo> regionInfos = new List<RegionInfo>();
84 83
85 int i = 0; 84 int i = 0;
86/*
87 foreach (string file in iniFiles) 85 foreach (string file in iniFiles)
88 { 86 {
89 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); 87 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
@@ -100,22 +98,17 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
100 i++; 98 i++;
101 } 99 }
102 } 100 }
103*/ 101
104 foreach (string file in configFiles) 102 foreach (string file in configFiles)
105 { 103 {
106 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); 104 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
107 105
108 IConfigSource source = new XmlConfigSource(file); 106 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource);
109 107 regionInfos.Add(regionInfo);
110 foreach (IConfig config in source.Configs)
111 {
112 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name);
113 regionInfos.Add(regionInfo);
114 108
115 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); 109 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
116 110
117 i++; 111 i++;
118 }
119 } 112 }
120 113
121 return regionInfos.ToArray(); 114 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
49 49
50 public RegionInfo[] LoadRegions() 50 public RegionInfo[] LoadRegions()
51 { 51 {
52 int tries = 3;
53 int wait = 2000;
54
52 if (m_configSource == null) 55 if (m_configSource == null)
53 { 56 {
54 m_log.Error("[WEBLOADER]: Unable to load configuration source!"); 57 m_log.Error("[WEBLOADER]: Unable to load configuration source!");
@@ -56,7 +59,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
56 } 59 }
57 else 60 else
58 { 61 {
59 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; 62 IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
60 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); 63 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
61 bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false); 64 bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
62 65
@@ -67,82 +70,75 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
67 } 70 }
68 else 71 else
69 { 72 {
70 RegionInfo[] regionInfos = new RegionInfo[] {}; 73 while (tries > 0)
71 int regionCount = 0;
72 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
73 webRequest.Timeout = 30000; //30 Second Timeout
74 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
75
76 try
77 { 74 {
78 string xmlSource = String.Empty; 75 RegionInfo[] regionInfos = new RegionInfo[] { };
76 int regionCount = 0;
77 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
78 webRequest.Timeout = 30000; //30 Second Timeout
79 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
79 80
80 using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse()) 81 try
81 { 82 {
83 HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
82 m_log.Debug("[WEBLOADER]: Downloading region information..."); 84 m_log.Debug("[WEBLOADER]: Downloading region information...");
83 85 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
84 using (Stream s = webResponse.GetResponseStream()) 86 string xmlSource = String.Empty;
87 string tempStr = reader.ReadLine();
88 while (tempStr != null)
85 { 89 {
86 using (StreamReader reader = new StreamReader(s)) 90 xmlSource = xmlSource + tempStr;
87 { 91 tempStr = reader.ReadLine();
88 string tempStr = reader.ReadLine();
89 while (tempStr != null)
90 {
91 xmlSource = xmlSource + tempStr;
92 tempStr = reader.ReadLine();
93 }
94 }
95 } 92 }
96 } 93 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
97 94 xmlSource.Length);
98 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + 95 XmlDocument xmlDoc = new XmlDocument();
99 xmlSource.Length); 96 xmlDoc.XmlResolver = null;
100 XmlDocument xmlDoc = new XmlDocument(); 97 xmlDoc.LoadXml(xmlSource);
101 xmlDoc.LoadXml(xmlSource); 98 if (xmlDoc.FirstChild.Name == "Nini")
102 if (xmlDoc.FirstChild.Name == "Nini")
103 {
104 regionCount = xmlDoc.FirstChild.ChildNodes.Count;
105
106 if (regionCount > 0)
107 { 99 {
108 regionInfos = new RegionInfo[regionCount]; 100 regionCount = xmlDoc.FirstChild.ChildNodes.Count;
109 int i; 101
110 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) 102 if (regionCount > 0)
111 { 103 {
112 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); 104 regionInfos = new RegionInfo[regionCount];
113 regionInfos[i] = 105 int i;
114 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); 106 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
107 {
108 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
109 regionInfos[i] =
110 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i], false, m_configSource);
111 }
115 } 112 }
116 } 113 }
117 } 114 }
118 } 115 catch (WebException ex)
119 catch (WebException ex)
120 {
121 using (HttpWebResponse response = (HttpWebResponse)ex.Response)
122 { 116 {
123 if (response.StatusCode == HttpStatusCode.NotFound) 117 if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
124 { 118 {
125 if (!allowRegionless) 119 if (!allowRegionless)
126 throw ex; 120 throw ex;
127 } 121 }
128 else 122 else
129 {
130 throw ex; 123 throw ex;
131 }
132 } 124 }
133 }
134 125
135 if (regionCount > 0 | allowRegionless) 126 if (regionCount > 0 | allowRegionless)
136 { 127 return regionInfos;
137 return regionInfos; 128
138 } 129 m_log.Debug("[WEBLOADER]: Request yielded no regions.");
139 else 130 tries--;
140 { 131 if (tries > 0)
141 m_log.Error("[WEBLOADER]: No region configs were available."); 132 {
142 return null; 133 m_log.Debug("[WEBLOADER]: Retrying");
134 System.Threading.Thread.Sleep(wait);
135 }
143 } 136 }
137
138 m_log.Error("[WEBLOADER]: No region configs were available.");
139 return null;
144 } 140 }
145 } 141 }
146 } 142 }
147 } 143 }
148} 144} \ No newline at end of file