Putting the requests back in the queue while testing for count >0 is not the smartest move...

cpu-performance
Diva Canto 2013-07-17 12:57:34 -07:00
parent 0f5b616fb0
commit f4317dc26d
1 changed files with 7 additions and 3 deletions

View File

@ -126,18 +126,22 @@ namespace OpenSim.Framework.Servers.HttpServer
Thread.Sleep(1000); Thread.Sleep(1000);
Watchdog.UpdateThread(); Watchdog.UpdateThread();
PollServiceHttpRequest req; List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
lock (m_longPollRequests) lock (m_longPollRequests)
{ {
while (m_longPollRequests.Count > 0 && m_running) while (m_longPollRequests.Count > 0 && m_running)
{ {
req = m_longPollRequests.Dequeue(); PollServiceHttpRequest req = m_longPollRequests.Dequeue();
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ
(Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout
m_requests.Enqueue(req); m_requests.Enqueue(req);
else else
m_longPollRequests.Enqueue(req); not_ready.Add(req);
} }
foreach (PollServiceHttpRequest req in not_ready)
m_longPollRequests.Enqueue(req);
} }
} }
} }