Revert "This is a completely unreasonable thing to do, effectively defying the purpose of BlockingQueues. Trying this, to see the effect on CPU."
This reverts commit 5232ab0496
.
cpu-performance
parent
1ba5a05cf7
commit
c685cc1799
|
@ -46,7 +46,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
|
|
||||||
private readonly BaseHttpServer m_server;
|
private readonly BaseHttpServer m_server;
|
||||||
|
|
||||||
private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
|
private DoubleQueue<PollServiceHttpRequest> m_requests = new DoubleQueue<PollServiceHttpRequest>();
|
||||||
private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>();
|
private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>();
|
||||||
|
|
||||||
private uint m_WorkerThreadCount = 0;
|
private uint m_WorkerThreadCount = 0;
|
||||||
|
@ -163,7 +163,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
m_requests.Enqueue(m_longPollRequests.Dequeue());
|
m_requests.Enqueue(m_longPollRequests.Dequeue());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (m_requests.Count() > 0)
|
while (m_requests.Count > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -185,33 +185,35 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
{
|
{
|
||||||
while (m_running)
|
while (m_running)
|
||||||
{
|
{
|
||||||
|
PollServiceHttpRequest req = m_requests.Dequeue(5000);
|
||||||
|
//m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString()));
|
||||||
|
|
||||||
Watchdog.UpdateThread();
|
Watchdog.UpdateThread();
|
||||||
|
if (req != null)
|
||||||
PollServiceHttpRequest req = null;
|
|
||||||
lock (m_requests)
|
|
||||||
{
|
{
|
||||||
if (m_requests.Count() > 0)
|
try
|
||||||
req = m_requests.Dequeue();
|
|
||||||
}
|
|
||||||
if (req == null)
|
|
||||||
Thread.Sleep(100);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//PollServiceHttpRequest req = m_requests.Dequeue(5000);
|
|
||||||
//m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString()));
|
|
||||||
|
|
||||||
if (req != null)
|
|
||||||
{
|
{
|
||||||
try
|
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
|
||||||
{
|
{
|
||||||
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
|
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
|
||||||
|
|
||||||
|
if (responsedata == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue
|
||||||
{
|
{
|
||||||
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
|
try
|
||||||
|
{
|
||||||
if (responsedata == null)
|
req.DoHTTPGruntWork(m_server, responsedata);
|
||||||
continue;
|
}
|
||||||
|
catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
|
||||||
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue
|
{
|
||||||
|
// Ignore it, no need to reply
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_threadPool.QueueWorkItem(x =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -221,41 +223,27 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
{
|
{
|
||||||
// Ignore it, no need to reply
|
// Ignore it, no need to reply
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_threadPool.QueueWorkItem(x =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
req.DoHTTPGruntWork(m_server, responsedata);
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
|
|
||||||
{
|
|
||||||
// Ignore it, no need to reply
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
|
||||||
|
{
|
||||||
|
req.DoHTTPGruntWork(
|
||||||
|
m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
|
ReQueueEvent(req);
|
||||||
{
|
|
||||||
req.DoHTTPGruntWork(
|
|
||||||
m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReQueueEvent(req);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
|
{
|
||||||
}
|
m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue