From f636ef037aa7bc7754ddb56d121e32e7823c8e73 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 16 Jul 2016 20:23:02 +0100 Subject: http send is blocking, so we need we need to do it async in all cases. - this will need revision after server changes --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 5 ++-- .../HttpServer/PollServiceRequestManager.cs | 30 +++++++++------------- 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 20bdf17..1ac5059 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -461,7 +461,8 @@ namespace OpenSim.Framework.Servers.HttpServer } OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); - resp.ReuseContext = true; +// resp.ReuseContext = true; + resp.ReuseContext = false; HandleRequest(req, resp); // !!!HACK ALERT!!! @@ -1954,7 +1955,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events - PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 3, 25000); + PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); PollServiceRequestManager.Start(); HTTPDRunning = true; diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 0e4323a..ffcad0f 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework.Servers.HttpServer STPStartInfo startInfo = new STPStartInfo(); startInfo.IdleTimeout = 30000; - startInfo.MaxWorkerThreads = 15; + startInfo.MaxWorkerThreads = 20; startInfo.MinWorkerThreads = 1; startInfo.ThreadPriority = ThreadPriority.Normal; startInfo.StartSuspended = true; @@ -160,7 +160,6 @@ namespace OpenSim.Framework.Servers.HttpServer } } - public void EnqueueInt(PollServiceHttpRequest req) { if (m_running) @@ -272,7 +271,7 @@ namespace OpenSim.Framework.Servers.HttpServer { Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); - if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue + m_threadPool.QueueWorkItem(x => { try { @@ -283,33 +282,28 @@ namespace OpenSim.Framework.Servers.HttpServer { // Ignore it, no need to reply } - } - else + return null; + }, null); + } + else + { + if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) { m_threadPool.QueueWorkItem(x => { try { - req.DoHTTPGruntWork(m_server, responsedata); + req.DoHTTPGruntWork(m_server, + req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); byContextDequeue(req); } - catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + catch (ObjectDisposedException) { - // Ignore it, no need to reply + // Ignore it, no need to reply } - return null; }, null); } - } - else - { - if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) - { - req.DoHTTPGruntWork(m_server, - req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); - byContextDequeue(req); - } else { ReQueueEvent(req); -- cgit v1.1