give BlockingCollection more chances

httptests
UbitUmarov 2018-01-22 00:43:33 +00:00
parent 73b587989c
commit d4a5454f3c
1 changed files with 24 additions and 23 deletions

View File

@ -28,14 +28,13 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Mono.Addins; using Mono.Addins;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -55,7 +54,7 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")]
public class WebFetchInvDescModule : INonSharedRegionModule public class WebFetchInvDescModule : INonSharedRegionModule
{ {
class aPollRequest class APollRequest
{ {
public PollServiceInventoryEventArgs thepoll; public PollServiceInventoryEventArgs thepoll;
public UUID reqID; public UUID reqID;
@ -98,8 +97,7 @@ namespace OpenSim.Region.ClientStack.Linden
private static Thread[] m_workerThreads = null; private static Thread[] m_workerThreads = null;
private static OpenSim.Framework.BlockingQueue<aPollRequest> m_queue = private static BlockingCollection<APollRequest> m_queue = new BlockingCollection<APollRequest>();
new OpenSim.Framework.BlockingQueue<aPollRequest>();
private static int m_NumberScenes = 0; private static int m_NumberScenes = 0;
@ -180,7 +178,7 @@ namespace OpenSim.Region.ClientStack.Linden
"httpfetch", "httpfetch",
StatType.Pull, StatType.Pull,
MeasuresOfInterest.AverageChangeOverTime, MeasuresOfInterest.AverageChangeOverTime,
stat => { stat.Value = m_queue.Count(); }, stat => { stat.Value = m_queue.Count; },
StatVerbosity.Debug); StatVerbosity.Debug);
StatsManager.RegisterStat(s_processedRequestsStat); StatsManager.RegisterStat(s_processedRequestsStat);
@ -290,7 +288,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
ScenePresence sp = m_module.Scene.GetScenePresence(Id); ScenePresence sp = m_module.Scene.GetScenePresence(Id);
aPollRequest reqinfo = new aPollRequest(); APollRequest reqinfo = new APollRequest();
reqinfo.thepoll = this; reqinfo.thepoll = this;
reqinfo.reqID = x; reqinfo.reqID = x;
reqinfo.request = y; reqinfo.request = y;
@ -347,7 +345,7 @@ namespace OpenSim.Region.ClientStack.Linden
m_queue.PriorityEnqueue(reqinfo); m_queue.PriorityEnqueue(reqinfo);
else else
*/ */
m_queue.Enqueue(reqinfo); m_queue.Add(reqinfo);
}; };
NoEvents = (x, y) => NoEvents = (x, y) =>
@ -371,7 +369,7 @@ namespace OpenSim.Region.ClientStack.Linden
}; };
} }
public void Process(aPollRequest requestinfo) public void Process(APollRequest requestinfo)
{ {
if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown) if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
return; return;
@ -477,23 +475,26 @@ namespace OpenSim.Region.ClientStack.Linden
private static void DoInventoryRequests() private static void DoInventoryRequests()
{ {
APollRequest poolreq;
while (true) while (true)
{ {
aPollRequest poolreq = m_queue.Dequeue(4500); if(!m_queue.TryTake(out poolreq, 4500) || poolreq == null || poolreq.thepoll == null)
Watchdog.UpdateThread();
if (poolreq != null && poolreq.thepoll != null)
{ {
try Watchdog.UpdateThread();
{ continue;
poolreq.thepoll.Process(poolreq); }
}
catch (Exception e) Watchdog.UpdateThread();
{ try
m_log.ErrorFormat( {
"[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}", APollRequest req = poolreq;
poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e); req.thepoll.Process(req);
} }
catch (Exception e)
{
m_log.ErrorFormat(
"[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}",
poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
} }
} }
} }