httpserver send is now async

master
UbitUmarov 2020-03-31 22:01:45 +01:00
parent e558dd3ac6
commit 817c2b3bb9
3 changed files with 28 additions and 12 deletions

View File

@ -231,6 +231,18 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
public int Priority
{
get
{
return _httpResponse.Priority;
}
set
{
_httpResponse.Priority = value;
}
}
/// <summary> /// <summary>
/// Set a redirct location. /// Set a redirct location.
/// </summary> /// </summary>

View File

@ -139,6 +139,9 @@ namespace OpenSim.Framework.Servers.HttpServer
if (responsedata.ContainsKey("keepalive")) if (responsedata.ContainsKey("keepalive"))
response.KeepAlive = (bool)responsedata["keepalive"]; response.KeepAlive = (bool)responsedata["keepalive"];
if (responsedata.ContainsKey("prio"))
response.Priority = (int)responsedata["prio"];
// Cross-Origin Resource Sharing with simple requests // Cross-Origin Resource Sharing with simple requests
if (responsedata.ContainsKey("access_control_allow_origin")) if (responsedata.ContainsKey("access_control_allow_origin"))
response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]); response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]);

View File

@ -51,7 +51,7 @@ namespace OpenSim.Framework.Servers.HttpServer
private bool m_running = false; private bool m_running = false;
private SmartThreadPool m_threadPool; //private SmartThreadPool m_threadPool;
public PollServiceRequestManager( public PollServiceRequestManager(
bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout)
@ -60,7 +60,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_workerThreads = new Thread[m_WorkerThreadCount]; m_workerThreads = new Thread[m_WorkerThreadCount];
m_bycontext = new Dictionary<int, Queue<PollServiceHttpRequest>>(256); m_bycontext = new Dictionary<int, Queue<PollServiceHttpRequest>>(256);
/*
STPStartInfo startInfo = new STPStartInfo(); STPStartInfo startInfo = new STPStartInfo();
startInfo.IdleTimeout = 30000; startInfo.IdleTimeout = 30000;
startInfo.MaxWorkerThreads = 20; startInfo.MaxWorkerThreads = 20;
@ -70,6 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer
startInfo.ThreadPoolName = "PoolService"; startInfo.ThreadPoolName = "PoolService";
m_threadPool = new SmartThreadPool(startInfo); m_threadPool = new SmartThreadPool(startInfo);
*/
} }
public void Start() public void Start()
@ -77,7 +78,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if(m_running) if(m_running)
return; return;
m_running = true; m_running = true;
m_threadPool.Start(); //m_threadPool.Start();
//startup worker threads //startup worker threads
for (uint i = 0; i < m_WorkerThreadCount; i++) for (uint i = 0; i < m_WorkerThreadCount; i++)
{ {
@ -192,7 +193,7 @@ namespace OpenSim.Framework.Servers.HttpServer
foreach (Thread t in m_workerThreads) foreach (Thread t in m_workerThreads)
Watchdog.AbortThread(t.ManagedThreadId); Watchdog.AbortThread(t.ManagedThreadId);
m_threadPool.Shutdown(); //m_threadPool.Shutdown();
// any entry in m_bycontext should have a active request on the other queues // any entry in m_bycontext should have a active request on the other queues
// so just delete contents to easy GC // 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)) if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
{ {
PollServiceHttpRequest nreq = req; PollServiceHttpRequest nreq = req;
m_threadPool.QueueWorkItem(x => //m_threadPool.QueueWorkItem(x =>
{ //{
try try
{ {
Hashtable responsedata = nreq.PollServiceArgs.GetEvents(nreq.RequestID, nreq.PollServiceArgs.Id); Hashtable responsedata = nreq.PollServiceArgs.GetEvents(nreq.RequestID, nreq.PollServiceArgs.Id);
@ -276,16 +277,16 @@ namespace OpenSim.Framework.Servers.HttpServer
byContextDequeue(nreq); byContextDequeue(nreq);
nreq = null; nreq = null;
} }
return null; //return null;
}, null); //}, null);
} }
else else
{ {
if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
{ {
PollServiceHttpRequest nreq = req; PollServiceHttpRequest nreq = req;
m_threadPool.QueueWorkItem(x => //m_threadPool.QueueWorkItem(x =>
{ //{
try try
{ {
nreq.DoHTTPGruntWork(nreq.PollServiceArgs.NoEvents(nreq.RequestID, nreq.PollServiceArgs.Id)); nreq.DoHTTPGruntWork(nreq.PollServiceArgs.NoEvents(nreq.RequestID, nreq.PollServiceArgs.Id));
@ -296,8 +297,8 @@ namespace OpenSim.Framework.Servers.HttpServer
byContextDequeue(nreq); byContextDequeue(nreq);
nreq = null; nreq = null;
} }
return null; //return null;
}, null); //}, null);
} }
else else
{ {