aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionLoader
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-02-27 00:21:02 +0000
committerJustin Clark-Casey (justincc)2013-02-27 00:21:02 +0000
commit80c19b7cac52a57fd04966169c657400aeee3de8 (patch)
tree32c48c0d00da28ed091d8c6a671d43d1e9ab8bdb /OpenSim/Framework/RegionLoader
parentminor: Remove unnecessary very old System.Net reference in OpenSim.Region.Scr... (diff)
downloadopensim-SC_OLD-80c19b7cac52a57fd04966169c657400aeee3de8.zip
opensim-SC_OLD-80c19b7cac52a57fd04966169c657400aeee3de8.tar.gz
opensim-SC_OLD-80c19b7cac52a57fd04966169c657400aeee3de8.tar.bz2
opensim-SC_OLD-80c19b7cac52a57fd04966169c657400aeee3de8.tar.xz
Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already.
Diffstat (limited to 'OpenSim/Framework/RegionLoader')
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs41
1 files changed, 29 insertions, 12 deletions
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
index a2f5d9c..05c64fa 100644
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
@@ -74,16 +74,26 @@ namespace OpenSim.Framework.RegionLoader.Web
74 74
75 try 75 try
76 { 76 {
77 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
78 m_log.Debug("[WEBLOADER]: Downloading region information...");
79 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
80 string xmlSource = String.Empty; 77 string xmlSource = String.Empty;
81 string tempStr = reader.ReadLine(); 78
82 while (tempStr != null) 79 using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse())
83 { 80 {
84 xmlSource = xmlSource + tempStr; 81 m_log.Debug("[WEBLOADER]: Downloading region information...");
85 tempStr = reader.ReadLine(); 82
83 using (Stream s = webResponse.GetResponseStream())
84 {
85 using (StreamReader reader = new StreamReader(s))
86 {
87 string tempStr = reader.ReadLine();
88 while (tempStr != null)
89 {
90 xmlSource = xmlSource + tempStr;
91 tempStr = reader.ReadLine();
92 }
93 }
94 }
86 } 95 }
96
87 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + 97 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
88 xmlSource.Length); 98 xmlSource.Length);
89 XmlDocument xmlDoc = new XmlDocument(); 99 XmlDocument xmlDoc = new XmlDocument();
@@ -107,17 +117,24 @@ namespace OpenSim.Framework.RegionLoader.Web
107 } 117 }
108 catch (WebException ex) 118 catch (WebException ex)
109 { 119 {
110 if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) 120 using (HttpWebResponse response = (HttpWebResponse)ex.Response)
111 { 121 {
112 if (!allowRegionless) 122 if (response.StatusCode == HttpStatusCode.NotFound)
123 {
124 if (!allowRegionless)
125 throw ex;
126 }
127 else
128 {
113 throw ex; 129 throw ex;
130 }
114 } 131 }
115 else
116 throw ex;
117 } 132 }
118 133
119 if (regionCount > 0 | allowRegionless) 134 if (regionCount > 0 | allowRegionless)
135 {
120 return regionInfos; 136 return regionInfos;
137 }
121 else 138 else
122 { 139 {
123 m_log.Error("[WEBLOADER]: No region configs were available."); 140 m_log.Error("[WEBLOADER]: No region configs were available.");
@@ -127,4 +144,4 @@ namespace OpenSim.Framework.RegionLoader.Web
127 } 144 }
128 } 145 }
129 } 146 }
130} 147} \ No newline at end of file