change threading on GetTexture and getMesh and WebFetch Modules.
parent
f16d36627f
commit
3029080d9b
|
@ -57,10 +57,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene;
|
||||
private string m_SceneName = "";
|
||||
private IAssetService m_AssetService;
|
||||
private bool m_Enabled = true;
|
||||
private bool m_IsRunning = false;
|
||||
private string m_URL;
|
||||
|
||||
private string m_URL2;
|
||||
|
@ -89,8 +87,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
private IAssetService m_assetService = null;
|
||||
|
||||
private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
|
||||
private Thread[] m_workerThreads = null;
|
||||
|
||||
private static Thread[] m_workerThreads = null;
|
||||
private static int m_NumberScenes = 0;
|
||||
private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
|
||||
new OpenMetaverse.BlockingQueue<aPollRequest>();
|
||||
|
||||
|
@ -146,7 +144,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
|
||||
m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
|
||||
m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate;
|
||||
|
||||
m_NumberScenes--;
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
|
@ -162,8 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
|
||||
m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate;
|
||||
|
||||
m_IsRunning = true;
|
||||
m_SceneName = m_scene.Name;
|
||||
m_NumberScenes++;
|
||||
|
||||
if (m_workerThreads == null)
|
||||
{
|
||||
|
@ -172,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
for (uint i = 0; i < 2; i++)
|
||||
{
|
||||
m_workerThreads[i] = WorkManager.StartThread(DoMeshRequests,
|
||||
String.Format("GetMeshWorker[{0}]{1}",m_SceneName, i),
|
||||
String.Format("GetMeshWorker{0}", i),
|
||||
ThreadPriority.Normal,
|
||||
false,
|
||||
false,
|
||||
|
@ -184,23 +181,22 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void Close()
|
||||
{
|
||||
if(m_IsRunning && m_workerThreads != null)
|
||||
if(m_NumberScenes <= 0 && m_workerThreads != null)
|
||||
{
|
||||
m_log.DebugFormat("[GetMeshModule] Closing{0}", m_SceneName);
|
||||
m_IsRunning = false;
|
||||
m_log.DebugFormat("[GetMeshModule] Closing");
|
||||
foreach (Thread t in m_workerThreads)
|
||||
Watchdog.AbortThread(t.ManagedThreadId);
|
||||
m_queue.Clear();
|
||||
}
|
||||
m_queue.Clear();
|
||||
}
|
||||
|
||||
public string Name { get { return "GetMeshModule"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
private void DoMeshRequests()
|
||||
private static void DoMeshRequests()
|
||||
{
|
||||
while (m_IsRunning)
|
||||
while(true)
|
||||
{
|
||||
aPollRequest poolreq = m_queue.Dequeue();
|
||||
Watchdog.UpdateThread();
|
||||
|
@ -299,6 +295,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
UUID requestID = requestinfo.reqID;
|
||||
|
||||
if(m_scene.ShuttingDown)
|
||||
return;
|
||||
|
||||
// If the avatar is gone, don't bother to get the texture
|
||||
if (m_scene.GetScenePresence(Id) == null)
|
||||
{
|
||||
|
@ -410,7 +409,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
User = puser;
|
||||
}
|
||||
|
||||
|
||||
public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
|
||||
{
|
||||
const float ThirtyPercent = 0.30f;
|
||||
|
@ -492,7 +490,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
PassTime();
|
||||
}
|
||||
|
||||
|
||||
private void PassTime()
|
||||
{
|
||||
currenttime = Util.EnvironmentTickCount();
|
||||
|
@ -511,6 +508,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AlterThrottle(int setting, ScenePresence p)
|
||||
{
|
||||
p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
|
||||
|
|
|
@ -75,17 +75,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
private IAssetService m_assetService = null;
|
||||
|
||||
private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
|
||||
private Thread[] m_workerThreads = null;
|
||||
|
||||
private string m_Url = "localhost";
|
||||
|
||||
private static Thread[] m_workerThreads = null;
|
||||
private static int m_NumberScenes = 0;
|
||||
private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
|
||||
new OpenMetaverse.BlockingQueue<aPollRequest>();
|
||||
|
||||
private Dictionary<UUID,PollServiceTextureEventArgs> m_pollservices = new Dictionary<UUID,PollServiceTextureEventArgs>();
|
||||
|
||||
private bool m_IsRunning = false;
|
||||
private string m_SceneName = "";
|
||||
private string m_Url = "localhost";
|
||||
|
||||
#region ISharedRegionModule Members
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
|
@ -117,6 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
|
||||
m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
|
||||
m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate;
|
||||
m_NumberScenes--;
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
|
@ -129,8 +128,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
|
||||
m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate;
|
||||
|
||||
m_SceneName = m_scene.Name;
|
||||
m_IsRunning = true;
|
||||
m_NumberScenes++;
|
||||
|
||||
if (m_workerThreads == null)
|
||||
{
|
||||
|
@ -139,7 +137,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
for (uint i = 0; i < 2; i++)
|
||||
{
|
||||
m_workerThreads[i] = WorkManager.StartThread(DoTextureRequests,
|
||||
String.Format("GetTextureWorker[{0}]{1}",m_SceneName, i),
|
||||
String.Format("GetTextureWorker{0}", i),
|
||||
ThreadPriority.Normal,
|
||||
false,
|
||||
false,
|
||||
|
@ -194,14 +192,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void Close()
|
||||
{
|
||||
if(m_IsRunning && m_workerThreads != null)
|
||||
if(m_NumberScenes <= 0 && m_workerThreads != null)
|
||||
{
|
||||
m_log.DebugFormat("[GetTextureModule] Closing {0}", m_SceneName);
|
||||
m_IsRunning = false;
|
||||
m_log.DebugFormat("[GetTextureModule] Closing");
|
||||
|
||||
foreach (Thread t in m_workerThreads)
|
||||
Watchdog.AbortThread(t.ManagedThreadId);
|
||||
|
||||
m_queue.Clear();
|
||||
}
|
||||
m_queue.Clear();
|
||||
}
|
||||
|
||||
public string Name { get { return "GetTextureModule"; } }
|
||||
|
@ -302,11 +301,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
UUID requestID = requestinfo.reqID;
|
||||
|
||||
if(m_scene.ShuttingDown)
|
||||
return;
|
||||
|
||||
if (requestinfo.send503)
|
||||
{
|
||||
response = new Hashtable();
|
||||
|
||||
|
||||
response["int_response_code"] = 503;
|
||||
response["str_response_string"] = "Throttled";
|
||||
response["content_type"] = "text/plain";
|
||||
|
@ -408,9 +409,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
}
|
||||
|
||||
private void DoTextureRequests()
|
||||
private static void DoTextureRequests()
|
||||
{
|
||||
while (m_IsRunning)
|
||||
while (true)
|
||||
{
|
||||
aPollRequest poolreq = m_queue.Dequeue();
|
||||
Watchdog.UpdateThread();
|
||||
|
|
|
@ -102,6 +102,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
private static DoubleQueue<aPollRequest> m_queue =
|
||||
new DoubleQueue<aPollRequest>();
|
||||
|
||||
private static int m_NumberScenes = 0;
|
||||
|
||||
#region ISharedRegionModule Members
|
||||
|
||||
public WebFetchInvDescModule() : this(true) {}
|
||||
|
@ -145,17 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
StatsManager.DeregisterStat(s_processedRequestsStat);
|
||||
StatsManager.DeregisterStat(s_queuedRequestsStat);
|
||||
|
||||
if (ProcessQueuedRequestsAsync)
|
||||
{
|
||||
if (m_workerThreads != null)
|
||||
{
|
||||
foreach (Thread t in m_workerThreads)
|
||||
Watchdog.AbortThread(t.ManagedThreadId);
|
||||
|
||||
m_workerThreads = null;
|
||||
}
|
||||
}
|
||||
|
||||
m_NumberScenes--;
|
||||
Scene = null;
|
||||
}
|
||||
|
||||
|
@ -203,6 +195,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
Scene.EventManager.OnRegisterCaps += RegisterCaps;
|
||||
|
||||
m_NumberScenes++;
|
||||
|
||||
int nworkers = 2; // was 2
|
||||
if (ProcessQueuedRequestsAsync && m_workerThreads == null)
|
||||
{
|
||||
|
@ -225,7 +219,23 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
{
|
||||
}
|
||||
|
||||
public void Close() { }
|
||||
public void Close()
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
if (ProcessQueuedRequestsAsync)
|
||||
{
|
||||
if (m_NumberScenes <= 0 && m_workerThreads != null)
|
||||
{
|
||||
m_log.DebugFormat("[WebFetchInvDescModule] Closing");
|
||||
foreach (Thread t in m_workerThreads)
|
||||
Watchdog.AbortThread(t.ManagedThreadId);
|
||||
|
||||
m_workerThreads = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get { return "WebFetchInvDescModule"; } }
|
||||
|
||||
|
@ -350,6 +360,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void Process(aPollRequest requestinfo)
|
||||
{
|
||||
if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
|
||||
return;
|
||||
|
||||
UUID requestID = requestinfo.reqID;
|
||||
|
||||
Hashtable response = new Hashtable();
|
||||
|
@ -425,31 +438,26 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
// }
|
||||
// }
|
||||
|
||||
private void DoInventoryRequests()
|
||||
private static void DoInventoryRequests()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Watchdog.UpdateThread();
|
||||
|
||||
WaitProcessQueuedInventoryRequest();
|
||||
}
|
||||
}
|
||||
aPollRequest poolreq = m_queue.Dequeue();
|
||||
|
||||
public void WaitProcessQueuedInventoryRequest()
|
||||
{
|
||||
aPollRequest poolreq = m_queue.Dequeue();
|
||||
|
||||
if (poolreq != null && poolreq.thepoll != null)
|
||||
{
|
||||
try
|
||||
if (poolreq != null && poolreq.thepoll != null)
|
||||
{
|
||||
poolreq.thepoll.Process(poolreq);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}. Exception {3}",
|
||||
poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e);
|
||||
try
|
||||
{
|
||||
poolreq.thepoll.Process(poolreq);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {3}",
|
||||
poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue