Reinstate explicit starting and stopping of PollServiceRequestManager added in 3eee991 but removed in 7c0bfca

Do not rely on destructors to stop things.
These fire at unpredictable times and cause problems such as http://opensimulator.org/mantis/view.php?id=6503
and most probably http://opensimulator.org/mantis/view.php?id=6668
cpu-performance
Justin Clark-Casey (justincc) 2013-06-10 23:30:35 +01:00
parent a2f1cd87f8
commit 32d1e50565
2 changed files with 7 additions and 4 deletions

View File

@ -1805,6 +1805,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// Long Poll Service Manager with 3 worker threads a 25 second timeout for no events // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000);
m_PollServiceManager.Start();
HTTPDRunning = true; HTTPDRunning = true;
//HttpListenerContext context; //HttpListenerContext context;
@ -1855,7 +1856,7 @@ namespace OpenSim.Framework.Servers.HttpServer
HTTPDRunning = false; HTTPDRunning = false;
try try
{ {
// m_PollServiceManager.Stop(); m_PollServiceManager.Stop();
m_httpListener2.ExceptionThrown -= httpServerException; m_httpListener2.ExceptionThrown -= httpServerException;
//m_httpListener2.DisconnectHandler = null; //m_httpListener2.DisconnectHandler = null;

View File

@ -66,7 +66,10 @@ namespace OpenSim.Framework.Servers.HttpServer
m_server = pSrv; m_server = pSrv;
m_WorkerThreadCount = pWorkerThreadCount; m_WorkerThreadCount = pWorkerThreadCount;
m_workerThreads = new Thread[m_WorkerThreadCount]; m_workerThreads = new Thread[m_WorkerThreadCount];
}
public void Start()
{
//startup worker threads //startup worker threads
for (uint i = 0; i < m_WorkerThreadCount; i++) for (uint i = 0; i < m_WorkerThreadCount; i++)
{ {
@ -91,7 +94,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1000 * 60 * 10); 1000 * 60 * 10);
} }
private void ReQueueEvent(PollServiceHttpRequest req) private void ReQueueEvent(PollServiceHttpRequest req)
{ {
if (m_running) if (m_running)
@ -142,14 +144,14 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
~PollServiceRequestManager() public void Stop()
{ {
m_running = false; m_running = false;
// m_timeout = -10000; // cause all to expire // m_timeout = -10000; // cause all to expire
Thread.Sleep(1000); // let the world move Thread.Sleep(1000); // let the world move
foreach (Thread t in m_workerThreads) foreach (Thread t in m_workerThreads)
Watchdog.AbortThread(t.ManagedThreadId); Watchdog.AbortThread(t.ManagedThreadId);
try try
{ {