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 --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 13 ++++++++++++- .../Framework/Servers/HttpServer/OSHttpResponse.cs | 13 +++++++++++++ .../HttpServer/PollServiceRequestManager.cs | 2 +- .../Servers/HttpServer/PollServiceWorkerThread.cs | 6 +++--- .../Region/ClientStack/LindenUDP/LLClientView.cs | 6 +++++- .../Framework/EventQueue/EventQueueGetModule.cs | 4 ++-- bin/HttpServer_OpenSim.dll | Bin 113152 -> 113664 bytes bin/HttpServer_OpenSim.pdb | Bin 302592 -> 304640 bytes 8 files changed, 36 insertions(+), 8 deletions(-) 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 { diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index c956421..e532939 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1616,8 +1616,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP agentData.child = false; agentData.firstname = m_firstName; agentData.lastname = m_lastName; - + ICapabilitiesModule capsModule = m_scene.RequestModuleInterface(); + + if (capsModule == null) // can happen when shutting down. + return agentData; + agentData.CapsPath = capsModule.GetCapsPath(m_agentId); agentData.ChildrenCapSeeds = new Dictionary(capsModule.GetChildrenSeeds(m_agentId)); diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs index 81b47be..c064df1 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs @@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/xml"; - responsedata["keepalive"] = false; + responsedata["keepalive"] = true; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); return responsedata; //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); @@ -386,7 +386,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 502; responsedata["content_type"] = "text/plain"; - responsedata["keepalive"] = false; + responsedata["keepalive"] = true; responsedata["str_response_string"] = "Upstream error: "; responsedata["error_status_text"] = "Upstream error:"; responsedata["http_protocol_version"] = "HTTP/1.0"; diff --git a/bin/HttpServer_OpenSim.dll b/bin/HttpServer_OpenSim.dll index 4775ec0..42b0d86 100644 Binary files a/bin/HttpServer_OpenSim.dll and b/bin/HttpServer_OpenSim.dll differ diff --git a/bin/HttpServer_OpenSim.pdb b/bin/HttpServer_OpenSim.pdb index b885eda..0c9e1f4 100644 Binary files a/bin/HttpServer_OpenSim.pdb and b/bin/HttpServer_OpenSim.pdb differ -- cgit v1.1