diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/LoadRegions')
4 files changed, 77 insertions, 76 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..4160483 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,14 @@ 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. | ||
72 | //// string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); | ||
73 | 71 | ||
74 | // Create an empty Regions.ini if there are no existing config files. | 72 | string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); |
73 | |||
74 | // Create an empty Regions.xml if there are no existing config files. | ||
75 | if (!allowRegionless && configFiles.Length == 0 /*&& iniFiles.Length == 0*/) | 75 | if (!allowRegionless && configFiles.Length == 0 /*&& iniFiles.Length == 0*/) |
76 | { | 76 | { |
77 | new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); | 77 | new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.xml"), false, m_configSource); |
78 | //// iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); | 78 | configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); |
79 | } | 79 | } |
80 | 80 | ||
81 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); | 81 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); |
@@ -83,7 +83,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
83 | List<RegionInfo> regionInfos = new List<RegionInfo>(); | 83 | List<RegionInfo> regionInfos = new List<RegionInfo>(); |
84 | 84 | ||
85 | int i = 0; | 85 | int i = 0; |
86 | /* | 86 | |
87 | IConfig regionConfig = (IConfig)m_configSource.Configs["Region"]; | ||
88 | string name = regionConfig.GetString("RegionName", string.Empty).Trim(); | ||
89 | if (string.Empty != name) | ||
90 | { | ||
91 | RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), string.Empty, false, m_configSource, name); | ||
92 | regionInfos.Add(regionInfo); | ||
93 | |||
94 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); | ||
95 | i++; | ||
96 | } | ||
97 | |||
87 | foreach (string file in iniFiles) | 98 | foreach (string file in iniFiles) |
88 | { | 99 | { |
89 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); | 100 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); |
@@ -100,25 +111,20 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
100 | i++; | 111 | i++; |
101 | } | 112 | } |
102 | } | 113 | } |
103 | */ | 114 | |
104 | foreach (string file in configFiles) | 115 | foreach (string file in configFiles) |
105 | { | 116 | { |
106 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); | 117 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); |
107 | 118 | ||
108 | IConfigSource source = new XmlConfigSource(file); | 119 | RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource); |
120 | regionInfos.Add(regionInfo); | ||
109 | 121 | ||
110 | foreach (IConfig config in source.Configs) | 122 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); |
111 | { | ||
112 | RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); | ||
113 | regionInfos.Add(regionInfo); | ||
114 | 123 | ||
115 | m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); | 124 | i++; |
116 | |||
117 | i++; | ||
118 | } | ||
119 | } | 125 | } |
120 | 126 | ||
121 | return regionInfos.ToArray(); | 127 | return regionInfos.ToArray(); |
122 | } | 128 | } |
123 | } | 129 | } |
124 | } \ No newline at end of file | 130 | } |
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 |