aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs101
1 files changed, 56 insertions, 45 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 025ffea..8d4e561 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -34,9 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using Mono.Addins; 35using Mono.Addins;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework; 37using OpenSim.Framework;
39using OpenSim.Framework.Monitoring;
40using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
@@ -45,6 +43,9 @@ using OpenSim.Framework.Capabilities;
45using OpenSim.Services.Interfaces; 43using OpenSim.Services.Interfaces;
46using Caps = OpenSim.Framework.Capabilities.Caps; 44using Caps = OpenSim.Framework.Capabilities.Caps;
47using OpenSim.Capabilities.Handlers; 45using OpenSim.Capabilities.Handlers;
46using OpenSim.Framework.Monitoring;
47
48using OpenMetaverse.StructuredData;
48 49
49namespace OpenSim.Region.ClientStack.Linden 50namespace OpenSim.Region.ClientStack.Linden
50{ 51{
@@ -63,7 +64,7 @@ namespace OpenSim.Region.ClientStack.Linden
63 public List<UUID> folders; 64 public List<UUID> folders;
64 } 65 }
65 66
66 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
67 68
68 /// <summary> 69 /// <summary>
69 /// Control whether requests will be processed asynchronously. 70 /// Control whether requests will be processed asynchronously.
@@ -92,14 +93,16 @@ namespace OpenSim.Region.ClientStack.Linden
92 private bool m_Enabled; 93 private bool m_Enabled;
93 94
94 private string m_fetchInventoryDescendents2Url; 95 private string m_fetchInventoryDescendents2Url;
95 private string m_webFetchInventoryDescendentsUrl; 96// private string m_webFetchInventoryDescendentsUrl;
96 97
97 private static FetchInvDescHandler m_webFetchHandler; 98 private static FetchInvDescHandler m_webFetchHandler;
98 99
99 private static Thread[] m_workerThreads = null; 100 private static Thread[] m_workerThreads = null;
100 101
101 private static DoubleQueue<aPollRequest> m_queue = 102 private static OpenSim.Framework.BlockingQueue<aPollRequest> m_queue =
102 new DoubleQueue<aPollRequest>(); 103 new OpenSim.Framework.BlockingQueue<aPollRequest>();
104
105 private static int m_NumberScenes = 0;
103 106
104 #region ISharedRegionModule Members 107 #region ISharedRegionModule Members
105 108
@@ -117,9 +120,10 @@ namespace OpenSim.Region.ClientStack.Linden
117 return; 120 return;
118 121
119 m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty); 122 m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty);
120 m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); 123// m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
121 124
122 if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty) 125// if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty)
126 if (m_fetchInventoryDescendents2Url != string.Empty)
123 { 127 {
124 m_Enabled = true; 128 m_Enabled = true;
125 } 129 }
@@ -143,17 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden
143 StatsManager.DeregisterStat(s_processedRequestsStat); 147 StatsManager.DeregisterStat(s_processedRequestsStat);
144 StatsManager.DeregisterStat(s_queuedRequestsStat); 148 StatsManager.DeregisterStat(s_queuedRequestsStat);
145 149
146 if (ProcessQueuedRequestsAsync) 150 m_NumberScenes--;
147 {
148 if (m_workerThreads != null)
149 {
150 foreach (Thread t in m_workerThreads)
151 Watchdog.AbortThread(t.ManagedThreadId);
152
153 m_workerThreads = null;
154 }
155 }
156
157 Scene = null; 151 Scene = null;
158 } 152 }
159 153
@@ -187,7 +181,7 @@ namespace OpenSim.Region.ClientStack.Linden
187 "httpfetch", 181 "httpfetch",
188 StatType.Pull, 182 StatType.Pull,
189 MeasuresOfInterest.AverageChangeOverTime, 183 MeasuresOfInterest.AverageChangeOverTime,
190 stat => { stat.Value = m_queue.Count; }, 184 stat => { stat.Value = m_queue.Count(); },
191 StatVerbosity.Debug); 185 StatVerbosity.Debug);
192 186
193 StatsManager.RegisterStat(s_processedRequestsStat); 187 StatsManager.RegisterStat(s_processedRequestsStat);
@@ -201,6 +195,8 @@ namespace OpenSim.Region.ClientStack.Linden
201 195
202 Scene.EventManager.OnRegisterCaps += RegisterCaps; 196 Scene.EventManager.OnRegisterCaps += RegisterCaps;
203 197
198 m_NumberScenes++;
199
204 int nworkers = 2; // was 2 200 int nworkers = 2; // was 2
205 if (ProcessQueuedRequestsAsync && m_workerThreads == null) 201 if (ProcessQueuedRequestsAsync && m_workerThreads == null)
206 { 202 {
@@ -211,7 +207,7 @@ namespace OpenSim.Region.ClientStack.Linden
211 m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests, 207 m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests,
212 String.Format("InventoryWorkerThread{0}", i), 208 String.Format("InventoryWorkerThread{0}", i),
213 ThreadPriority.Normal, 209 ThreadPriority.Normal,
214 false, 210 true,
215 true, 211 true,
216 null, 212 null,
217 int.MaxValue); 213 int.MaxValue);
@@ -223,7 +219,23 @@ namespace OpenSim.Region.ClientStack.Linden
223 { 219 {
224 } 220 }
225 221
226 public void Close() { } 222 public void Close()
223 {
224 if (!m_Enabled)
225 return;
226
227 if (ProcessQueuedRequestsAsync)
228 {
229 if (m_NumberScenes <= 0 && m_workerThreads != null)
230 {
231 m_log.DebugFormat("[WebFetchInvDescModule] Closing");
232 foreach (Thread t in m_workerThreads)
233 Watchdog.AbortThread(t.ManagedThreadId);
234
235 m_workerThreads = null;
236 }
237 }
238 }
227 239
228 public string Name { get { return "WebFetchInvDescModule"; } } 240 public string Name { get { return "WebFetchInvDescModule"; } }
229 241
@@ -312,16 +324,17 @@ namespace OpenSim.Region.ClientStack.Linden
312 { 324 {
313 if (!reqinfo.folders.Contains(folderID)) 325 if (!reqinfo.folders.Contains(folderID))
314 { 326 {
315 //TODO: Port COF handling from Avination 327 if (sp.COF != UUID.Zero && sp.COF == folderID)
328 highPriority = true;
316 reqinfo.folders.Add(folderID); 329 reqinfo.folders.Add(folderID);
317 } 330 }
318 } 331 }
319 } 332 }
320 333
321 if (highPriority) 334 if (highPriority)
322 m_queue.EnqueueHigh(reqinfo); 335 m_queue.PriorityEnqueue(reqinfo);
323 else 336 else
324 m_queue.EnqueueLow(reqinfo); 337 m_queue.Enqueue(reqinfo);
325 }; 338 };
326 339
327 NoEvents = (x, y) => 340 NoEvents = (x, y) =>
@@ -347,6 +360,9 @@ namespace OpenSim.Region.ClientStack.Linden
347 360
348 public void Process(aPollRequest requestinfo) 361 public void Process(aPollRequest requestinfo)
349 { 362 {
363 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
364 return;
365
350 UUID requestID = requestinfo.reqID; 366 UUID requestID = requestinfo.reqID;
351 367
352 Hashtable response = new Hashtable(); 368 Hashtable response = new Hashtable();
@@ -365,7 +381,8 @@ namespace OpenSim.Region.ClientStack.Linden
365 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); 381 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
366 responses[requestID] = response; 382 responses[requestID] = response;
367 } 383 }
368 384 requestinfo.folders.Clear();
385 requestinfo.request.Clear();
369 WebFetchInvDescModule.ProcessedRequestsCount++; 386 WebFetchInvDescModule.ProcessedRequestsCount++;
370 } 387 }
371 } 388 }
@@ -422,31 +439,25 @@ namespace OpenSim.Region.ClientStack.Linden
422// } 439// }
423// } 440// }
424 441
425 private void DoInventoryRequests() 442 private static void DoInventoryRequests()
426 { 443 {
427 while (true) 444 while (true)
428 { 445 {
446 aPollRequest poolreq = m_queue.Dequeue(4500);
429 Watchdog.UpdateThread(); 447 Watchdog.UpdateThread();
430 448
431 WaitProcessQueuedInventoryRequest(); 449 if (poolreq != null && poolreq.thepoll != null)
432 }
433 }
434
435 public void WaitProcessQueuedInventoryRequest()
436 {
437 aPollRequest poolreq = m_queue.Dequeue();
438
439 if (poolreq != null && poolreq.thepoll != null)
440 {
441 try
442 {
443 poolreq.thepoll.Process(poolreq);
444 }
445 catch (Exception e)
446 { 450 {
447 m_log.ErrorFormat( 451 try
448 "[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}. Exception {3}", 452 {
449 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e); 453 poolreq.thepoll.Process(poolreq);
454 }
455 catch (Exception e)
456 {
457 m_log.ErrorFormat(
458 "[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}",
459 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
460 }
450 } 461 }
451 } 462 }
452 } 463 }