PollServiceRequestManager: changed the long poll from a Queue to a List. No need to dequeue and enqueue items every 1sec.
parent
52bb732692
commit
d30e5f7ded
|
@ -47,7 +47,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 BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
|
||||||
private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>();
|
private static List<PollServiceHttpRequest> m_longPollRequests = new List<PollServiceHttpRequest>();
|
||||||
|
|
||||||
private uint m_WorkerThreadCount = 0;
|
private uint m_WorkerThreadCount = 0;
|
||||||
private Thread[] m_workerThreads;
|
private Thread[] m_workerThreads;
|
||||||
|
@ -116,7 +116,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll)
|
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll)
|
||||||
{
|
{
|
||||||
lock (m_longPollRequests)
|
lock (m_longPollRequests)
|
||||||
m_longPollRequests.Enqueue(req);
|
m_longPollRequests.Add(req);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_requests.Enqueue(req);
|
m_requests.Enqueue(req);
|
||||||
|
@ -139,18 +139,21 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
|
List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
|
||||||
lock (m_longPollRequests)
|
lock (m_longPollRequests)
|
||||||
{
|
{
|
||||||
while (m_longPollRequests.Count > 0 && m_running)
|
if (m_longPollRequests.Count > 0 && m_running)
|
||||||
{
|
{
|
||||||
PollServiceHttpRequest req = m_longPollRequests.Dequeue();
|
List<PollServiceHttpRequest> ready = m_longPollRequests.FindAll(req =>
|
||||||
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ
|
(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);
|
);
|
||||||
else
|
|
||||||
not_ready.Add(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (PollServiceHttpRequest req in not_ready)
|
ready.ForEach(req =>
|
||||||
m_longPollRequests.Enqueue(req);
|
{
|
||||||
|
m_log.DebugFormat("[YYY]: --> Enqueuing");
|
||||||
|
m_requests.Enqueue(req);
|
||||||
|
m_longPollRequests.Remove(req);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,8 +172,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
|
|
||||||
lock (m_longPollRequests)
|
lock (m_longPollRequests)
|
||||||
{
|
{
|
||||||
while (m_longPollRequests.Count > 0 && m_running)
|
if (m_longPollRequests.Count > 0 && m_running)
|
||||||
m_requests.Enqueue(m_longPollRequests.Dequeue());
|
m_longPollRequests.ForEach(req => m_requests.Enqueue(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (m_requests.Count() > 0)
|
while (m_requests.Count() > 0)
|
||||||
|
@ -186,6 +189,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_longPollRequests.Clear();
|
||||||
m_requests.Clear();
|
m_requests.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue