From f04d51378f864d2eb522678b3fb1e239f746bd35 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 3 Aug 2010 11:06:41 -0700 Subject: Drop the RestClient timeout from 15 minutes to 30 seconds. This does not address the problem, but it will allow the regions to recover in the event that the remote server goes away. --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications/RestClient.cs') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 97b3b60..42c0b18 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -363,7 +363,7 @@ namespace OpenSim.Framework.Communications _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; - _request.Timeout = 900000; + _request.Timeout = 30000; _request.Method = RequestMethod; _asyncException = null; _request.ContentLength = src.Length; -- cgit v1.1 From 9bf3e2a25745000fc9113c4b00f280fa67460601 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 17 Sep 2014 15:36:22 +0100 Subject: dispose some tmp streams --- OpenSim/Framework/Communications/RestClient.cs | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications/RestClient.cs') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 42c0b18..de34250 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -329,15 +329,16 @@ namespace OpenSim.Framework.Communications return null; } - Stream src = _response.GetResponseStream(); - int length = src.Read(_readbuf, 0, BufferSize); - while (length > 0) + using (Stream src = _response.GetResponseStream()) { - _resource.Write(_readbuf, 0, length); - length = src.Read(_readbuf, 0, BufferSize); + int length = src.Read(_readbuf, 0, BufferSize); + while (length > 0) + { + _resource.Write(_readbuf, 0, length); + length = src.Read(_readbuf, 0, BufferSize); + } } - // TODO! Implement timeout, without killing the server // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); @@ -372,16 +373,19 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); m_log.Info("[REST]: Seek is ok"); - Stream dst = _request.GetRequestStream(); - m_log.Info("[REST]: GetRequestStream is ok"); - byte[] buf = new byte[1024]; - int length = src.Read(buf, 0, 1024); - m_log.Info("[REST]: First Read is ok"); - while (length > 0) + using (Stream dst = _request.GetRequestStream()) { - dst.Write(buf, 0, length); - length = src.Read(buf, 0, 1024); + m_log.Info("[REST]: GetRequestStream is ok"); + + byte[] buf = new byte[1024]; + int length = src.Read(buf, 0, 1024); + m_log.Info("[REST]: First Read is ok"); + while (length > 0) + { + dst.Write(buf, 0, length); + length = src.Read(buf, 0, 1024); + } } _response = (HttpWebResponse) _request.GetResponse(); -- cgit v1.1 From df389dceb8b9430049c3bedf3632b4df2eb91e15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 17 Sep 2014 16:19:00 +0100 Subject: add some _response.close. RestClient still looks bad. It should be a proper IDisposable object. --- OpenSim/Framework/Communications/RestClient.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Framework/Communications/RestClient.cs') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index de34250..ce36fbf 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -326,6 +326,9 @@ namespace OpenSim.Framework.Communications m_log.Debug(e.ToString()); } + if (_response != null) + _response.Close(); + return null; } @@ -390,6 +393,9 @@ namespace OpenSim.Framework.Communications _response = (HttpWebResponse) _request.GetResponse(); + if (_response != null) + _response.Close(); + // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); // TODO! Implement timeout, without killing the server -- cgit v1.1