aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
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/Region
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/Region')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs30
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs21
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs12
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs46
5 files changed, 71 insertions, 54 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 689e8a7..f04fabe 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -838,13 +838,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
838 try 838 try
839 { 839 {
840 WebRequest request = HttpWebRequest.Create(url); 840 WebRequest request = HttpWebRequest.Create(url);
841//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 841
842//Ckrinke Stream str = null; 842 using (HttpWebResponse response = (HttpWebResponse)(request).GetResponse())
843 HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
844 if (response.StatusCode == HttpStatusCode.OK)
845 { 843 {
846 Bitmap image = new Bitmap(response.GetResponseStream()); 844 if (response.StatusCode == HttpStatusCode.OK)
847 return image; 845 {
846 using (Stream s = response.GetResponseStream())
847 {
848 Bitmap image = new Bitmap(s);
849 return image;
850 }
851 }
848 } 852 }
849 } 853 }
850 catch { } 854 catch { }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 912d50a..c50ab64 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -868,20 +868,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
868 } 868 }
869 869
870 string response_mapItems_reply = null; 870 string response_mapItems_reply = null;
871 { // get the response 871 {
872 StreamReader sr = null;
873 try 872 try
874 { 873 {
875 WebResponse webResponse = mapitemsrequest.GetResponse(); 874 using (WebResponse webResponse = mapitemsrequest.GetResponse())
876 if (webResponse != null)
877 {
878 sr = new StreamReader(webResponse.GetResponseStream());
879 response_mapItems_reply = sr.ReadToEnd().Trim();
880 }
881 else
882 { 875 {
883 return new OSDMap(); 876 if (webResponse != null)
884 } 877 {
878 using (Stream s = webResponse.GetResponseStream())
879 using (StreamReader sr = new StreamReader(s))
880 response_mapItems_reply = sr.ReadToEnd().Trim();
881 }
882 else
883 {
884 return new OSDMap();
885 }
886 }
885 } 887 }
886 catch (WebException) 888 catch (WebException)
887 { 889 {
@@ -908,11 +910,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
908 910
909 return responseMap; 911 return responseMap;
910 } 912 }
911 finally
912 {
913 if (sr != null)
914 sr.Close();
915 }
916 913
917 OSD rezResponse = null; 914 OSD rezResponse = null;
918 try 915 try
@@ -926,6 +923,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
926 { 923 {
927 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); 924 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
928 responseMap["connect"] = OSD.FromBoolean(false); 925 responseMap["connect"] = OSD.FromBoolean(false);
926
929 lock (m_blacklistedregions) 927 lock (m_blacklistedregions)
930 { 928 {
931 if (!m_blacklistedregions.ContainsKey(regionhandle)) 929 if (!m_blacklistedregions.ContainsKey(regionhandle))
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 37ab35a..ef1b92e 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -551,13 +551,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
551 reqStream.Close(); 551 reqStream.Close();
552 } 552 }
553 553
554 HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); 554 using (HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse())
555 Encoding encoding = Util.UTF8; 555 {
556 StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); 556 Encoding encoding = Util.UTF8;
557 fwdresponsestr = fwdresponsestream.ReadToEnd(); 557
558 fwdresponsecontenttype = fwdrsp.ContentType; 558 using (Stream s = fwdrsp.GetResponseStream())
559 fwdresponsecode = (int)fwdrsp.StatusCode; 559 {
560 fwdresponsestream.Close(); 560 using (StreamReader fwdresponsestream = new StreamReader(s))
561 {
562 fwdresponsestr = fwdresponsestream.ReadToEnd();
563 fwdresponsecontenttype = fwdrsp.ContentType;
564 fwdresponsecode = (int)fwdrsp.StatusCode;
565 }
566 }
567 }
561 568
562 response["content_type"] = fwdresponsecontenttype; 569 response["content_type"] = fwdresponsecontenttype;
563 response["str_response_string"] = fwdresponsestr; 570 response["str_response_string"] = fwdresponsestr;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index 881807a..cb69411 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -1116,18 +1116,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1116 // Otherwise prepare the request 1116 // Otherwise prepare the request
1117 m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); 1117 m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
1118 1118
1119 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); 1119 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
1120 HttpWebResponse rsp = null;
1121 1120
1122 // We are sending just parameters, no content 1121 // We are sending just parameters, no content
1123 req.ContentLength = 0; 1122 req.ContentLength = 0;
1124 1123
1125 // Send request and retrieve the response 1124 // Send request and retrieve the response
1126 rsp = (HttpWebResponse)req.GetResponse(); 1125 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
1127 1126 using (Stream s = rsp.GetResponseStream())
1128 XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream()); 1127 using (XmlTextReader rdr = new XmlTextReader(s))
1129 doc.Load(rdr); 1128 doc.Load(rdr);
1130 rdr.Close();
1131 } 1129 }
1132 catch (Exception e) 1130 catch (Exception e)
1133 { 1131 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 1101851..71b24ac 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -1146,28 +1146,38 @@ namespace Nwc.XmlRpc
1146 request.AllowWriteStreamBuffering = true; 1146 request.AllowWriteStreamBuffering = true;
1147 request.KeepAlive = !_disableKeepAlive; 1147 request.KeepAlive = !_disableKeepAlive;
1148 1148
1149 Stream stream = request.GetRequestStream(); 1149 using (Stream stream = request.GetRequestStream())
1150 XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
1151 _serializer.Serialize(xml, this);
1152 xml.Flush();
1153 xml.Close();
1154
1155 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
1156 StreamReader input = new StreamReader(response.GetResponseStream());
1157
1158 string inputXml = input.ReadToEnd();
1159 XmlRpcResponse resp;
1160 try
1161 { 1150 {
1162 resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml); 1151 using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
1152 {
1153 _serializer.Serialize(xml, this);
1154 xml.Flush();
1155 }
1163 } 1156 }
1164 catch (Exception e) 1157
1158 XmlRpcResponse resp;
1159
1160 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
1165 { 1161 {
1166 RequestResponse = inputXml; 1162 using (Stream s = response.GetResponseStream())
1167 throw e; 1163 {
1164 using (StreamReader input = new StreamReader(s))
1165 {
1166 string inputXml = input.ReadToEnd();
1167
1168 try
1169 {
1170 resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
1171 }
1172 catch (Exception e)
1173 {
1174 RequestResponse = inputXml;
1175 throw e;
1176 }
1177 }
1178 }
1168 } 1179 }
1169 input.Close(); 1180
1170 response.Close();
1171 return resp; 1181 return resp;
1172 } 1182 }
1173 } 1183 }