From 817c2b3bb956c13d56e7b1435df078fa69f0038d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 31 Mar 2020 22:01:45 +0100 Subject: [PATCH] httpserver send is now async --- .../Servers/HttpServer/OSHttpResponse.cs | 12 +++++++++ .../HttpServer/PollServiceHttpRequest.cs | 3 +++ .../HttpServer/PollServiceRequestManager.cs | 25 ++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index 5a49881902..b505d4eb13 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs @@ -231,6 +231,18 @@ namespace OpenSim.Framework.Servers.HttpServer } } + public int Priority + { + get + { + return _httpResponse.Priority; + } + set + { + _httpResponse.Priority = value; + } + } + /// /// Set a redirct location. /// diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index ac7b2dbe9b..2f89034259 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs @@ -139,6 +139,9 @@ namespace OpenSim.Framework.Servers.HttpServer if (responsedata.ContainsKey("keepalive")) response.KeepAlive = (bool)responsedata["keepalive"]; + if (responsedata.ContainsKey("prio")) + response.Priority = (int)responsedata["prio"]; + // Cross-Origin Resource Sharing with simple requests if (responsedata.ContainsKey("access_control_allow_origin")) response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 790aa99974..93dc9c83ca 100755 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Servers.HttpServer private bool m_running = false; - private SmartThreadPool m_threadPool; + //private SmartThreadPool m_threadPool; public PollServiceRequestManager( bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Servers.HttpServer m_workerThreads = new Thread[m_WorkerThreadCount]; m_bycontext = new Dictionary>(256); - + /* STPStartInfo startInfo = new STPStartInfo(); startInfo.IdleTimeout = 30000; startInfo.MaxWorkerThreads = 20; @@ -70,6 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer startInfo.ThreadPoolName = "PoolService"; m_threadPool = new SmartThreadPool(startInfo); + */ } public void Start() @@ -77,7 +78,7 @@ namespace OpenSim.Framework.Servers.HttpServer if(m_running) return; m_running = true; - m_threadPool.Start(); + //m_threadPool.Start(); //startup worker threads for (uint i = 0; i < m_WorkerThreadCount; i++) { @@ -192,7 +193,7 @@ namespace OpenSim.Framework.Servers.HttpServer foreach (Thread t in m_workerThreads) Watchdog.AbortThread(t.ManagedThreadId); - m_threadPool.Shutdown(); + //m_threadPool.Shutdown(); // any entry in m_bycontext should have a active request on the other queues // so just delete contents to easy GC @@ -263,8 +264,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { PollServiceHttpRequest nreq = req; - m_threadPool.QueueWorkItem(x => - { + //m_threadPool.QueueWorkItem(x => + //{ try { Hashtable responsedata = nreq.PollServiceArgs.GetEvents(nreq.RequestID, nreq.PollServiceArgs.Id); @@ -276,16 +277,16 @@ namespace OpenSim.Framework.Servers.HttpServer byContextDequeue(nreq); nreq = null; } - return null; - }, null); + //return null; + //}, null); } else { if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) { PollServiceHttpRequest nreq = req; - m_threadPool.QueueWorkItem(x => - { + //m_threadPool.QueueWorkItem(x => + //{ try { nreq.DoHTTPGruntWork(nreq.PollServiceArgs.NoEvents(nreq.RequestID, nreq.PollServiceArgs.Id)); @@ -296,8 +297,8 @@ namespace OpenSim.Framework.Servers.HttpServer byContextDequeue(nreq); nreq = null; } - return null; - }, null); + //return null; + //}, null); } else {