From e66321227e06ddc9d01eb2c47b00ea74ce3ec80c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 2 Oct 2009 16:23:46 -0700 Subject: Close streams in MakeRequest. --- .../HttpServer/AsynchronousRestObjectRequester.cs | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs index fe69ad3..48e1370 100644 --- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs @@ -91,24 +91,31 @@ namespace OpenSim.Framework.Servers.HttpServer Stream requestStream = request.EndGetRequestStream(res); requestStream.Write(buffer.ToArray(), 0, length); + requestStream.Close(); request.BeginGetResponse(delegate(IAsyncResult ar) { response = request.EndGetResponse(ar); - + Stream respStream = null; try { - deserial = (TResponse) deserializer.Deserialize( - response.GetResponseStream()); + respStream = response.GetResponseStream(); + deserial = (TResponse)deserializer.Deserialize( + respStream); } catch (System.InvalidOperationException) { } + finally + { + respStream.Close(); + response.Close(); + } action(deserial); }, null); }, null); - + return; } @@ -119,14 +126,21 @@ namespace OpenSim.Framework.Servers.HttpServer // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't // documented in MSDN response = request.EndGetResponse(res2); - + + Stream respStream = null; try { - deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); + respStream = response.GetResponseStream(); + deserial = (TResponse)deserializer.Deserialize(respStream); } catch (System.InvalidOperationException) { } + finally + { + respStream.Close(); + response.Close(); + } } catch (WebException e) { -- cgit v1.1