diff options
Diffstat (limited to 'OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs')
-rw-r--r-- | OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | 133 |
1 files changed, 64 insertions, 69 deletions
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index 05c64fa..65de563 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | |||
@@ -48,6 +48,9 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
48 | 48 | ||
49 | public RegionInfo[] LoadRegions() | 49 | public RegionInfo[] LoadRegions() |
50 | { | 50 | { |
51 | int tries = 3; | ||
52 | int wait = 2000; | ||
53 | |||
51 | if (m_configSource == null) | 54 | if (m_configSource == null) |
52 | { | 55 | { |
53 | m_log.Error("[WEBLOADER]: Unable to load configuration source!"); | 56 | m_log.Error("[WEBLOADER]: Unable to load configuration source!"); |
@@ -66,82 +69,74 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
66 | } | 69 | } |
67 | else | 70 | else |
68 | { | 71 | { |
69 | RegionInfo[] regionInfos = new RegionInfo[] {}; | 72 | while(tries > 0) |
70 | int regionCount = 0; | 73 | { |
71 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); | 74 | RegionInfo[] regionInfos = new RegionInfo[] {}; |
72 | webRequest.Timeout = 30000; //30 Second Timeout | 75 | int regionCount = 0; |
73 | m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); | 76 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); |
74 | 77 | webRequest.Timeout = 30000; //30 Second Timeout | |
75 | try | 78 | m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); |
76 | { | ||
77 | string xmlSource = String.Empty; | ||
78 | |||
79 | using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse()) | ||
80 | { | ||
81 | m_log.Debug("[WEBLOADER]: Downloading region information..."); | ||
82 | 79 | ||
83 | using (Stream s = webResponse.GetResponseStream()) | 80 | try |
81 | { | ||
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 == "Nini") | ||
84 | { | 97 | { |
85 | using (StreamReader reader = new StreamReader(s)) | 98 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; |
86 | { | 99 | |
87 | string tempStr = reader.ReadLine(); | 100 | if (regionCount > 0) |
88 | while (tempStr != null) | 101 | { |
89 | { | 102 | regionInfos = new RegionInfo[regionCount]; |
90 | xmlSource = xmlSource + tempStr; | 103 | int i; |
91 | tempStr = reader.ReadLine(); | 104 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) |
92 | } | 105 | { |
93 | } | 106 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); |
94 | } | 107 | regionInfos[i] = |
95 | } | 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 | } | ||
96 | 123 | ||
97 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | 124 | if (regionCount > 0 | allowRegionless) |
98 | xmlSource.Length); | 125 | return regionInfos; |
99 | XmlDocument xmlDoc = new XmlDocument(); | 126 | |
100 | xmlDoc.LoadXml(xmlSource); | 127 | m_log.Debug("[WEBLOADER]: Request yielded no regions."); |
101 | if (xmlDoc.FirstChild.Name == "Regions") | 128 | tries--; |
102 | { | 129 | if (tries > 0) |
103 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; | ||
104 | |||
105 | if (regionCount > 0) | ||
106 | { | ||
107 | regionInfos = new RegionInfo[regionCount]; | ||
108 | int i; | ||
109 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) | ||
110 | { | ||
111 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); | ||
112 | regionInfos[i] = | ||
113 | new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | catch (WebException ex) | ||
119 | { | ||
120 | using (HttpWebResponse response = (HttpWebResponse)ex.Response) | ||
121 | { | 130 | { |
122 | if (response.StatusCode == HttpStatusCode.NotFound) | 131 | m_log.Debug("[WEBLOADER]: Retrying"); |
123 | { | 132 | System.Threading.Thread.Sleep(wait); |
124 | if (!allowRegionless) | ||
125 | throw ex; | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | throw ex; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | if (regionCount > 0 | allowRegionless) | 136 | m_log.Error("[WEBLOADER]: No region configs were available."); |
135 | { | 137 | return null; |
136 | return regionInfos; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | m_log.Error("[WEBLOADER]: No region configs were available."); | ||
141 | return null; | ||
142 | } | ||
143 | } | 138 | } |
144 | } | 139 | } |
145 | } | 140 | } |
146 | } | 141 | } |
147 | } \ No newline at end of file | 142 | } |