Change the poll service to use a thread pool for replies to make sure the

event queues aren't blocked by other traffic.
avinationmerge
Melanie 2012-09-23 23:16:25 +02:00
parent 64db9e4114
commit 2d02405186
2 changed files with 39 additions and 7 deletions

View File

@ -33,6 +33,7 @@ using log4net;
using HttpServer;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using Amib.Threading;
/*
@ -185,6 +186,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private bool m_running = true;
private int slowCount = 0;
private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2);
// private int m_timeout = 1000; // increase timeout 250; now use the event one
public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
@ -353,6 +356,10 @@ namespace OpenSim.Framework.Servers.HttpServer
continue;
}
// "Normal" means the viewer evebt queue. We need to push these out fast.
// Process them inline. The rest go to the thread pool.
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal)
{
try
{
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
@ -362,8 +369,32 @@ namespace OpenSim.Framework.Servers.HttpServer
{
// Ignore it, no need to reply
}
finally
{
str.Close();
}
}
else
{
m_threadPool.QueueWorkItem(x =>
{
try
{
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
DoHTTPGruntWork(m_server, req, responsedata);
}
catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
{
// Ignore it, no need to reply
}
finally
{
str.Close();
}
return null;
}, null);
}
}
else

View File

@ -162,6 +162,7 @@
<Reference name="XMLRPC" path="../../../../bin/"/>
<Reference name="log4net" path="../../../../bin/"/>
<Reference name="HttpServer_OpenSim" path="../../../../bin/"/>
<Reference name="SmartThreadPool"/>
<Files>
<Match pattern="*.cs" recurse="true">