From df7049008acd394fa514db584f56d0e3925a2d77 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 3 Oct 2009 08:57:30 -0700 Subject: More streams closed. --- .../Servers/HttpServer/RestSessionService.cs | 19 +++++++++++++++++-- .../HttpServer/SynchronousRestFormsRequester.cs | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 3f72c31..6c0aa46 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs @@ -88,6 +88,7 @@ namespace OpenSim.Framework.Servers.HttpServer serializer.Serialize(writer, sobj); writer.Flush(); } + buffer.Close(); int length = (int)buffer.Length; request.ContentLength = length; @@ -99,8 +100,19 @@ namespace OpenSim.Framework.Servers.HttpServer using (WebResponse resp = request.GetResponse()) { XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); - resp.Close(); + Stream respStream = null; + try + { + respStream = resp.GetResponseStream(); + deserial = (TResponse)deserializer.Deserialize(respStream); + } + catch { } + finally + { + if (respStream != null) + respStream.Close(); + resp.Close(); + } } return deserial; } @@ -140,6 +152,7 @@ namespace OpenSim.Framework.Servers.HttpServer serializer.Serialize(writer, sobj); writer.Flush(); } + buffer.Close(); int length = (int)buffer.Length; request.ContentLength = length; @@ -165,6 +178,8 @@ namespace OpenSim.Framework.Servers.HttpServer // m_log.DebugFormat("[REST OBJECT POSTER RESPONSE]: Received {0}", reader.ReadToEnd()); deserial = (TResponse)deserializer.Deserialize(stream); + if (stream != null) + stream.Close(); if (deserial != null && ResponseCallback != null) { diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs index 85622a1..e76d80e 100644 --- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs @@ -62,6 +62,7 @@ namespace OpenSim.Framework.Servers.HttpServer writer.Write(obj); writer.Flush(); } + buffer.Close(); length = (int)obj.Length; request.ContentLength = length; -- cgit v1.1