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.cs101
1 files changed, 68 insertions, 33 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 8d4e561..1113002 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) =>
@@ -352,36 +364,56 @@ namespace OpenSim.Region.ClientStack.Linden
352 response["str_response_string"] = "Script timeout"; 364 response["str_response_string"] = "Script timeout";
353 response["content_type"] = "text/plain"; 365 response["content_type"] = "text/plain";
354 response["keepalive"] = false; 366 response["keepalive"] = false;
355 response["reusecontext"] = false;
356 367
357 return response; 368 return response;
358 }; 369 };
359 } 370 }
360 371
361 public void Process(aPollRequest requestinfo) 372 public void Process(APollRequest requestinfo)
362 { 373 {
363 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown) 374 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
364 return; 375 return;
365 376
366 UUID requestID = requestinfo.reqID; 377 UUID requestID = requestinfo.reqID;
367 378
379
380 lock(responses)
381 {
382 lock(dropedResponses)
383 {
384 if(dropedResponses.Contains(requestID))
385 {
386 dropedResponses.Remove(requestID);
387 return;
388 }
389 }
390 }
391
368 Hashtable response = new Hashtable(); 392 Hashtable response = new Hashtable();
369 393
370 response["int_response_code"] = 200; 394 response["int_response_code"] = 200;
371 response["content_type"] = "text/plain"; 395 response["content_type"] = "text/plain";
372 response["keepalive"] = false;
373 response["reusecontext"] = false;
374 396
375 response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( 397 response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(
376 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); 398 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
377 399
378 lock (responses) 400 lock (responses)
379 { 401 {
402 lock(dropedResponses)
403 {
404 if(dropedResponses.Contains(requestID))
405 {
406 dropedResponses.Remove(requestID);
407 requestinfo.request.Clear();
408 WebFetchInvDescModule.ProcessedRequestsCount++;
409 return;
410 }
411 }
412
380 if (responses.ContainsKey(requestID)) 413 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"); 414 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
382 responses[requestID] = response; 415 responses[requestID] = response;
383 } 416 }
384 requestinfo.folders.Clear();
385 requestinfo.request.Clear(); 417 requestinfo.request.Clear();
386 WebFetchInvDescModule.ProcessedRequestsCount++; 418 WebFetchInvDescModule.ProcessedRequestsCount++;
387 } 419 }
@@ -441,23 +473,26 @@ namespace OpenSim.Region.ClientStack.Linden
441 473
442 private static void DoInventoryRequests() 474 private static void DoInventoryRequests()
443 { 475 {
476 APollRequest poolreq;
444 while (true) 477 while (true)
445 { 478 {
446 aPollRequest poolreq = m_queue.Dequeue(4500); 479 if(!m_queue.TryTake(out poolreq, 4500) || poolreq == null || poolreq.thepoll == null)
447 Watchdog.UpdateThread(); 480 {
481 Watchdog.UpdateThread();
482 continue;
483 }
448 484
449 if (poolreq != null && poolreq.thepoll != null) 485 Watchdog.UpdateThread();
486 try
450 { 487 {
451 try 488 APollRequest req = poolreq;
452 { 489 req.thepoll.Process(req);
453 poolreq.thepoll.Process(poolreq); 490 }
454 } 491 catch (Exception e)
455 catch (Exception e) 492 {
456 { 493 m_log.ErrorFormat(
457 m_log.ErrorFormat( 494 "[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}", 495 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
459 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
460 }
461 } 496 }
462 } 497 }
463 } 498 }