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>
/// Set a redirct location.
/// </summary>

View File

@ -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"]);

View File

@ -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<int, Queue<PollServiceHttpRequest>>(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
{