From f727f26bcc26a740a1bd0585e3cdeff0c8d81a25 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 29 Jul 2009 20:32:54 +0000 Subject: * An attempt to fix mantis #3953 --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 13 ++++++++++++- OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs | 13 +++++++++++++ .../Servers/HttpServer/PollServiceRequestManager.cs | 2 +- .../Framework/Servers/HttpServer/PollServiceWorkerThread.cs | 6 +++--- 4 files changed, 29 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 369d7d4..f2a1da0 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -274,7 +274,7 @@ namespace OpenSim.Framework.Servers.HttpServer public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) { OSHttpRequest req = new OSHttpRequest(context, request); - OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request)); + OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); //resp.KeepAlive = req.KeepAlive; //m_log.Info("[Debug BASE HTTP SERVER]: Got Request"); //HttpServerContextObj objstate= new HttpServerContextObj(req,resp); @@ -444,6 +444,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException e) { @@ -746,6 +747,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException e) { @@ -778,6 +780,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException e) { @@ -888,6 +891,7 @@ namespace OpenSim.Framework.Servers.HttpServer { response.Send(); response.OutputStream.Flush(); + response.FreeContext(); //response.OutputStream.Close(); } catch (IOException e) @@ -1103,6 +1107,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException f) { @@ -1377,7 +1382,11 @@ namespace OpenSim.Framework.Servers.HttpServer //response.OutputStream.Close(); try { + response.OutputStream.Flush(); response.Send(); + + if (!response.KeepAlive) + response.FreeContext(); } catch (SocketException e) { @@ -1414,6 +1423,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException e) { @@ -1449,6 +1459,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { response.Send(); + response.FreeContext(); } catch (SocketException e) { diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index d299001..6c90a92 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs @@ -258,6 +258,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected IHttpResponse _httpResponse; + private IHttpClientContext _httpClientContext; public OSHttpResponse() {} @@ -275,6 +276,12 @@ namespace OpenSim.Framework.Servers.HttpServer public OSHttpResponse(OSHttpRequest req) { _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest); + _httpClientContext = req.IHttpClientContext; + } + public OSHttpResponse(HttpResponse resp, IHttpClientContext clientContext) + { + _httpResponse = resp; + _httpClientContext = clientContext; } /// @@ -298,5 +305,11 @@ namespace OpenSim.Framework.Servers.HttpServer _httpResponse.Send(); } + public void FreeContext() + { + if (_httpClientContext != null) + _httpClientContext.Close(); + } + } } diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 7f632cf..a9ee217 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -130,7 +130,7 @@ namespace OpenSim.Framework.Servers.HttpServer foreach (object o in m_requests) { PollServiceHttpRequest req = (PollServiceHttpRequest) o; - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request))); + m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); } m_requests.Clear(); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index 4c0be78..24205eb 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_request; private bool m_running = true; - private int m_timeout = 25000; + private int m_timeout = 250; @@ -71,14 +71,14 @@ namespace OpenSim.Framework.Servers.HttpServer Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); m_server.DoHTTPGruntWork(responsedata, - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request))); + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); } else { if ((Environment.TickCount - req.RequestTime) > m_timeout) { m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request))); + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); } else { -- cgit v1.1