give BlockingCollection another chance

httptests
UbitUmarov 2018-01-21 21:02:07 +00:00
parent ccdaebaed6
commit 855dcda9c3
1 changed files with 14 additions and 17 deletions

View File

@ -44,7 +44,7 @@ namespace OpenSim.Framework.Servers.HttpServer
private readonly BaseHttpServer m_server; private readonly BaseHttpServer m_server;
private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext; private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext;
private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>();
private static ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>(); private static ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>();
private uint m_WorkerThreadCount = 0; private uint m_WorkerThreadCount = 0;
@ -166,7 +166,7 @@ namespace OpenSim.Framework.Servers.HttpServer
public void EnqueueInt(PollServiceHttpRequest req) public void EnqueueInt(PollServiceHttpRequest req)
{ {
if (m_running) if (m_running)
m_requests.Enqueue(req); m_requests.Add(req);
} }
private void CheckRetries() private void CheckRetries()
@ -177,7 +177,7 @@ namespace OpenSim.Framework.Servers.HttpServer
Thread.Sleep(100); Thread.Sleep(100);
Watchdog.UpdateThread(); Watchdog.UpdateThread();
while (m_running && m_retryRequests.TryDequeue(out preq)) while (m_running && m_retryRequests.TryDequeue(out preq))
m_requests.Enqueue(preq); m_requests.Add(preq);
} }
} }
@ -198,9 +198,9 @@ namespace OpenSim.Framework.Servers.HttpServer
qu.Clear(); qu.Clear();
m_bycontext.Clear(); m_bycontext.Clear();
PollServiceHttpRequest req;
try try
{ {
PollServiceHttpRequest req;
while(m_retryRequests.TryDequeue(out req)) while(m_retryRequests.TryDequeue(out req))
req.DoHTTPstop(m_server); req.DoHTTPstop(m_server);
} }
@ -208,21 +208,17 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
} }
PollServiceHttpRequest wreq; try
{
while (m_requests.Count() > 0) while(m_requests.TryTake(out req, 0))
req.DoHTTPstop(m_server);
}
catch
{ {
try
{
wreq = m_requests.Dequeue(0);
wreq.DoHTTPstop(m_server);
}
catch
{
}
} }
m_requests.Clear(); m_requests.Dispose();
} }
// work threads // work threads
@ -231,7 +227,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
while (m_running) while (m_running)
{ {
PollServiceHttpRequest req = m_requests.Dequeue(4500); PollServiceHttpRequest req;
m_requests.TryTake(out req, 4500);
Watchdog.UpdateThread(); Watchdog.UpdateThread();
if(req == null) if(req == null)
continue; continue;