aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs98
1 files changed, 68 insertions, 30 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 8d4e561..f6d49ee 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -28,14 +28,13 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections.Concurrent;
31using System.Reflection; 32using System.Reflection;
32using System.Threading; 33using System.Threading;
33using log4net; 34using log4net;
34using Nini.Config; 35using Nini.Config;
35using Mono.Addins; 36using Mono.Addins;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -55,13 +54,12 @@ namespace OpenSim.Region.ClientStack.Linden
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] 54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")]
56 public class WebFetchInvDescModule : INonSharedRegionModule 55 public class WebFetchInvDescModule : INonSharedRegionModule
57 { 56 {
58 class aPollRequest 57 class APollRequest
59 { 58 {
60 public PollServiceInventoryEventArgs thepoll; 59 public PollServiceInventoryEventArgs thepoll;
61 public UUID reqID; 60 public UUID reqID;
62 public Hashtable request; 61 public Hashtable request;
63 public ScenePresence presence; 62 public ScenePresence presence;
64 public List<UUID> folders;
65 } 63 }
66 64
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -99,8 +97,7 @@ namespace OpenSim.Region.ClientStack.Linden
99 97
100 private static Thread[] m_workerThreads = null; 98 private static Thread[] m_workerThreads = null;
101 99
102 private static OpenSim.Framework.BlockingQueue<aPollRequest> m_queue = 100 private static BlockingCollection<APollRequest> m_queue = new BlockingCollection<APollRequest>();
103 new OpenSim.Framework.BlockingQueue<aPollRequest>();
104 101
105 private static int m_NumberScenes = 0; 102 private static int m_NumberScenes = 0;
106 103
@@ -181,7 +178,7 @@ namespace OpenSim.Region.ClientStack.Linden
181 "httpfetch", 178 "httpfetch",
182 StatType.Pull, 179 StatType.Pull,
183 MeasuresOfInterest.AverageChangeOverTime, 180 MeasuresOfInterest.AverageChangeOverTime,
184 stat => { stat.Value = m_queue.Count(); }, 181 stat => { stat.Value = m_queue.Count; },
185 StatVerbosity.Debug); 182 StatVerbosity.Debug);
186 183
187 StatsManager.RegisterStat(s_processedRequestsStat); 184 StatsManager.RegisterStat(s_processedRequestsStat);
@@ -235,6 +232,7 @@ namespace OpenSim.Region.ClientStack.Linden
235 m_workerThreads = null; 232 m_workerThreads = null;
236 } 233 }
237 } 234 }
235// m_queue.Dispose();
238 } 236 }
239 237
240 public string Name { get { return "WebFetchInvDescModule"; } } 238 public string Name { get { return "WebFetchInvDescModule"; } }
@@ -250,17 +248,28 @@ namespace OpenSim.Region.ClientStack.Linden
250 { 248 {
251 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 249 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
252 250
253 private Dictionary<UUID, Hashtable> responses = 251 private Dictionary<UUID, Hashtable> responses = new Dictionary<UUID, Hashtable>();
254 new Dictionary<UUID, Hashtable>(); 252 private HashSet<UUID> dropedResponses = new HashSet<UUID>();
255 253
256 private WebFetchInvDescModule m_module; 254 private WebFetchInvDescModule m_module;
257 255
258 public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : 256 public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) :
259 base(null, url, null, null, null, pId, int.MaxValue) 257 base(null, url, null, null, null, null, pId, int.MaxValue)
260 { 258 {
261 m_module = module; 259 m_module = module;
262 260
263 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; 261 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
262
263 Drop = (x, y) =>
264 {
265 lock (responses)
266 {
267 responses.Remove(x);
268 lock(dropedResponses)
269 dropedResponses.Add(x);
270 }
271 };
272
264 GetEvents = (x, y) => 273 GetEvents = (x, y) =>
265 { 274 {
266 lock (responses) 275 lock (responses)
@@ -280,13 +289,15 @@ namespace OpenSim.Region.ClientStack.Linden
280 { 289 {
281 ScenePresence sp = m_module.Scene.GetScenePresence(Id); 290 ScenePresence sp = m_module.Scene.GetScenePresence(Id);
282 291
283 aPollRequest reqinfo = new aPollRequest(); 292 APollRequest reqinfo = new APollRequest();
284 reqinfo.thepoll = this; 293 reqinfo.thepoll = this;
285 reqinfo.reqID = x; 294 reqinfo.reqID = x;
286 reqinfo.request = y; 295 reqinfo.request = y;
287 reqinfo.presence = sp; 296 reqinfo.presence = sp;
288 reqinfo.folders = new List<UUID>();
289 297
298/* why where we doing this? just to get cof ?
299 List<UUID> folders = new List<UUID>();
300
290 // Decode the request here 301 // Decode the request here
291 string request = y["body"].ToString(); 302 string request = y["body"].ToString();
292 303
@@ -322,11 +333,11 @@ namespace OpenSim.Region.ClientStack.Linden
322 UUID folderID; 333 UUID folderID;
323 if (UUID.TryParse(folder, out folderID)) 334 if (UUID.TryParse(folder, out folderID))
324 { 335 {
325 if (!reqinfo.folders.Contains(folderID)) 336 if (!folders.Contains(folderID))
326 { 337 {
327 if (sp.COF != UUID.Zero && sp.COF == folderID) 338 if (sp.COF != UUID.Zero && sp.COF == folderID)
328 highPriority = true; 339 highPriority = true;
329 reqinfo.folders.Add(folderID); 340 folders.Add(folderID);
330 } 341 }
331 } 342 }
332 } 343 }
@@ -334,7 +345,8 @@ namespace OpenSim.Region.ClientStack.Linden
334 if (highPriority) 345 if (highPriority)
335 m_queue.PriorityEnqueue(reqinfo); 346 m_queue.PriorityEnqueue(reqinfo);
336 else 347 else
337 m_queue.Enqueue(reqinfo); 348*/
349 m_queue.Add(reqinfo);
338 }; 350 };
339 351
340 NoEvents = (x, y) => 352 NoEvents = (x, y) =>
@@ -358,13 +370,26 @@ namespace OpenSim.Region.ClientStack.Linden
358 }; 370 };
359 } 371 }
360 372
361 public void Process(aPollRequest requestinfo) 373 public void Process(APollRequest requestinfo)
362 { 374 {
363 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown) 375 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
364 return; 376 return;
365 377
366 UUID requestID = requestinfo.reqID; 378 UUID requestID = requestinfo.reqID;
367 379
380
381 lock(responses)
382 {
383 lock(dropedResponses)
384 {
385 if(dropedResponses.Contains(requestID))
386 {
387 dropedResponses.Remove(requestID);
388 return;
389 }
390 }
391 }
392
368 Hashtable response = new Hashtable(); 393 Hashtable response = new Hashtable();
369 394
370 response["int_response_code"] = 200; 395 response["int_response_code"] = 200;
@@ -377,11 +402,21 @@ namespace OpenSim.Region.ClientStack.Linden
377 402
378 lock (responses) 403 lock (responses)
379 { 404 {
405 lock(dropedResponses)
406 {
407 if(dropedResponses.Contains(requestID))
408 {
409 dropedResponses.Remove(requestID);
410 requestinfo.request.Clear();
411 WebFetchInvDescModule.ProcessedRequestsCount++;
412 return;
413 }
414 }
415
380 if (responses.ContainsKey(requestID)) 416 if (responses.ContainsKey(requestID))
381 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); 417 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
382 responses[requestID] = response; 418 responses[requestID] = response;
383 } 419 }
384 requestinfo.folders.Clear();
385 requestinfo.request.Clear(); 420 requestinfo.request.Clear();
386 WebFetchInvDescModule.ProcessedRequestsCount++; 421 WebFetchInvDescModule.ProcessedRequestsCount++;
387 } 422 }
@@ -441,23 +476,26 @@ namespace OpenSim.Region.ClientStack.Linden
441 476
442 private static void DoInventoryRequests() 477 private static void DoInventoryRequests()
443 { 478 {
479 APollRequest poolreq;
444 while (true) 480 while (true)
445 { 481 {
446 aPollRequest poolreq = m_queue.Dequeue(4500); 482 if(!m_queue.TryTake(out poolreq, 4500) || poolreq == null || poolreq.thepoll == null)
447 Watchdog.UpdateThread(); 483 {
484 Watchdog.UpdateThread();
485 continue;
486 }
448 487
449 if (poolreq != null && poolreq.thepoll != null) 488 Watchdog.UpdateThread();
489 try
450 { 490 {
451 try 491 APollRequest req = poolreq;
452 { 492 req.thepoll.Process(req);
453 poolreq.thepoll.Process(poolreq); 493 }
454 } 494 catch (Exception e)
455 catch (Exception e) 495 {
456 { 496 m_log.ErrorFormat(
457 m_log.ErrorFormat( 497 "[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}",
458 "[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}", 498 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
459 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
460 }
461 } 499 }
462 } 500 }
463 } 501 }