diff options
Merge commit '39d7945efc8daa6e5cd0f4728b499e7a624526cd' into bigmerge
Conflicts:
OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
Diffstat (limited to 'OpenSim/Framework/RegionLoader')
-rw-r--r-- | OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | 93 |
2 files changed, 62 insertions, 35 deletions
diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index 0aae4ff..8332c14 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs | |||
@@ -48,11 +48,13 @@ namespace OpenSim.Framework.RegionLoader.Filesystem | |||
48 | public RegionInfo[] LoadRegions() | 48 | public RegionInfo[] LoadRegions() |
49 | { | 49 | { |
50 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); | 50 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); |
51 | bool allowRegionless = false; | ||
51 | 52 | ||
52 | try | 53 | try |
53 | { | 54 | { |
54 | IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; | 55 | IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; |
55 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); | 56 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); |
57 | allowRegionless = startupConfig.GetBoolean("allow_regionless", false); | ||
56 | } | 58 | } |
57 | catch (Exception) | 59 | catch (Exception) |
58 | { | 60 | { |
@@ -68,7 +70,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem | |||
68 | string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); | 70 | string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); |
69 | 71 | ||
70 | // Create an empty Regions.ini if there are no existing config files. | 72 | // Create an empty Regions.ini if there are no existing config files. |
71 | if (configFiles.Length == 0 && iniFiles.Length == 0) | 73 | if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0) |
72 | { | 74 | { |
73 | new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); | 75 | new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); |
74 | iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); | 76 | iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); |
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index f0ffc2c..c7caf6f 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | |||
@@ -60,6 +60,8 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
60 | { | 60 | { |
61 | IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; | 61 | IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; |
62 | string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); | 62 | string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); |
63 | bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false); | ||
64 | |||
63 | if (url == String.Empty) | 65 | if (url == String.Empty) |
64 | { | 66 | { |
65 | m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty."); | 67 | m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty."); |
@@ -67,39 +69,60 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
67 | } | 69 | } |
68 | else | 70 | else |
69 | { | 71 | { |
70 | while (tries > 0) | 72 | while(tries > 0) |
71 | { | 73 | { |
72 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); | 74 | RegionInfo[] regionInfos = new RegionInfo[] {}; |
73 | webRequest.Timeout = 30000; //30 Second Timeout | 75 | int regionCount = 0; |
74 | m_log.Debug("[WEBLOADER]: Sending Download Request..."); | 76 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); |
75 | HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); | 77 | webRequest.Timeout = 30000; //30 Second Timeout |
76 | m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server..."); | 78 | m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); |
77 | StreamReader reader = new StreamReader(webResponse.GetResponseStream()); | ||
78 | string xmlSource = String.Empty; | ||
79 | string tempStr = reader.ReadLine(); | ||
80 | while (tempStr != null) | ||
81 | { | ||
82 | xmlSource = xmlSource + tempStr; | ||
83 | tempStr = reader.ReadLine(); | ||
84 | } | ||
85 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | ||
86 | xmlSource.Length); | ||
87 | XmlDocument xmlDoc = new XmlDocument(); | ||
88 | xmlDoc.LoadXml(xmlSource); | ||
89 | if (xmlDoc.FirstChild.Name == "Regions") | ||
90 | { | ||
91 | RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; | ||
92 | int i; | ||
93 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) | ||
94 | { | ||
95 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); | ||
96 | regionInfos[i] = | ||
97 | new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); | ||
98 | } | ||
99 | 79 | ||
100 | if (i > 0) | 80 | try |
101 | return regionInfos; | 81 | { |
102 | } | 82 | HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); |
83 | m_log.Debug("[WEBLOADER]: Downloading region information..."); | ||
84 | StreamReader reader = new StreamReader(webResponse.GetResponseStream()); | ||
85 | string xmlSource = String.Empty; | ||
86 | string tempStr = reader.ReadLine(); | ||
87 | while (tempStr != null) | ||
88 | { | ||
89 | xmlSource = xmlSource + tempStr; | ||
90 | tempStr = reader.ReadLine(); | ||
91 | } | ||
92 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | ||
93 | xmlSource.Length); | ||
94 | XmlDocument xmlDoc = new XmlDocument(); | ||
95 | xmlDoc.LoadXml(xmlSource); | ||
96 | if (xmlDoc.FirstChild.Name == "Regions") | ||
97 | { | ||
98 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; | ||
99 | |||
100 | if (regionCount > 0) | ||
101 | { | ||
102 | regionInfos = new RegionInfo[regionCount]; | ||
103 | int i; | ||
104 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) | ||
105 | { | ||
106 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); | ||
107 | regionInfos[i] = | ||
108 | new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | catch (WebException ex) | ||
114 | { | ||
115 | if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) | ||
116 | { | ||
117 | if (!allowRegionless) | ||
118 | throw ex; | ||
119 | } | ||
120 | else | ||
121 | throw ex; | ||
122 | } | ||
123 | |||
124 | if (regionCount > 0 | allowRegionless) | ||
125 | return regionInfos; | ||
103 | 126 | ||
104 | m_log.Debug("[WEBLOADER]: Request yielded no regions."); | 127 | m_log.Debug("[WEBLOADER]: Request yielded no regions."); |
105 | tries--; | 128 | tries--; |
@@ -108,8 +131,10 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
108 | m_log.Debug("[WEBLOADER]: Retrying"); | 131 | m_log.Debug("[WEBLOADER]: Retrying"); |
109 | System.Threading.Thread.Sleep(wait); | 132 | System.Threading.Thread.Sleep(wait); |
110 | } | 133 | } |
111 | } | 134 | } |
112 | return null; | 135 | |
136 | m_log.Error("[WEBLOADER]: No region configs were available."); | ||
137 | return null; | ||
113 | } | 138 | } |
114 | } | 139 | } |
115 | } | 140 | } |