From 805deb5a9ba51307393dc5e11b100c86ee7c1b79 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 31 Aug 2008 10:42:35 +0000 Subject: Attempt to fix an issue I havebeen seeing, where asset server failure results in a memory leak which will make the region crash and burn after a while. --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 3 +++ OpenSim/Framework/Communications/RestClient.cs | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 9cccf66..1c947dc 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -63,6 +63,9 @@ namespace OpenSim.Framework.Communications.Cache Stream s = rc.Request(); + if (s == null) + return null; + if (s.Length > 0) { XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index b71a590..7d45186 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -286,7 +286,18 @@ namespace OpenSim.Framework.Communications _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse) _request.GetResponse(); + try + { + _response = (HttpWebResponse) _request.GetResponse(); + } + catch (System.Net.WebException e) + { + m_log.ErrorFormat("[ASSET] Error fetching asset from asset server"); + m_log.Debug(e.ToString()); + + return null; + } + Stream src = _response.GetResponseStream(); int length = src.Read(_readbuf, 0, BufferSize); while (length > 0) -- cgit v1.1