aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
diff options
context:
space:
mode:
authorUbitUmarov2014-07-25 13:03:40 +0100
committerUbitUmarov2014-07-25 13:03:40 +0100
commitfa59cddc28c107e47f8549b3944fa5f14f561926 (patch)
treeab2b44351c6f3d492e3062831ee120e11729d3d2 /OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
parent change previus code, send a NoEvents response back to http server, even (diff)
downloadopensim-SC-fa59cddc28c107e47f8549b3944fa5f14f561926.zip
opensim-SC-fa59cddc28c107e47f8549b3944fa5f14f561926.tar.gz
opensim-SC-fa59cddc28c107e47f8549b3944fa5f14f561926.tar.bz2
opensim-SC-fa59cddc28c107e47f8549b3944fa5f14f561926.tar.xz
remove old and dead code that its only making it hard to understand
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs305
1 files changed, 18 insertions, 287 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 4a2ac86..ddae267 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -77,7 +77,6 @@ namespace OpenSim.Region.ClientStack.Linden
77 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); 77 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
78 78
79 private Dictionary<UUID, Queue<OSD>> queues = new Dictionary<UUID, Queue<OSD>>(); 79 private Dictionary<UUID, Queue<OSD>> queues = new Dictionary<UUID, Queue<OSD>>();
80 private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>();
81 private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); 80 private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>();
82 81
83 #region INonSharedRegionModule methods 82 #region INonSharedRegionModule methods
@@ -254,28 +253,13 @@ namespace OpenSim.Region.ClientStack.Linden
254 lock (queues) 253 lock (queues)
255 queues.Remove(agentID); 254 queues.Remove(agentID);
256 255
257 List<UUID> removeitems = new List<UUID>();
258 lock (m_AvatarQueueUUIDMapping) 256 lock (m_AvatarQueueUUIDMapping)
259 m_AvatarQueueUUIDMapping.Remove(agentID); 257 m_AvatarQueueUUIDMapping.Remove(agentID);
260 258
261 UUID searchval = UUID.Zero; 259 lock (m_ids)
262
263 removeitems.Clear();
264
265 lock (m_QueueUUIDAvatarMapping)
266 { 260 {
267 foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys) 261 if (!m_ids.ContainsKey(agentID))
268 { 262 m_ids.Remove(agentID);
269 searchval = m_QueueUUIDAvatarMapping[ky];
270
271 if (searchval == agentID)
272 {
273 removeitems.Add(ky);
274 }
275 }
276
277 foreach (UUID ky in removeitems)
278 m_QueueUUIDAvatarMapping.Remove(ky);
279 } 263 }
280 264
281 // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); 265 // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
@@ -307,28 +291,18 @@ namespace OpenSim.Region.ClientStack.Linden
307 lock (m_AvatarQueueUUIDMapping) 291 lock (m_AvatarQueueUUIDMapping)
308 { 292 {
309 // Reuse open queues. The client does! 293 // Reuse open queues. The client does!
310// if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) 294 // Its reuse caps path not queues those are been reused already
311// { 295 if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
312 //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
313// eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
314// }
315// else
316 { 296 {
317 eventQueueGetUUID = UUID.Random(); 297 m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
318 //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); 298 eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
319 } 299 }
320 } 300 else
321 301 {
322 lock (m_QueueUUIDAvatarMapping) 302 eventQueueGetUUID = UUID.Random();
323 {
324 if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID))
325 m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID);
326 }
327
328 lock (m_AvatarQueueUUIDMapping)
329 {
330 if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID))
331 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); 303 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
304 m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
305 }
332 } 306 }
333 307
334 caps.RegisterPollHandler( 308 caps.RegisterPollHandler(
@@ -336,10 +310,14 @@ namespace OpenSim.Region.ClientStack.Linden
336 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); 310 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));
337 311
338 Random rnd = new Random(Environment.TickCount); 312 Random rnd = new Random(Environment.TickCount);
313 int nrnd = rnd.Next(30000000);
314
339 lock (m_ids) 315 lock (m_ids)
340 { 316 {
341 if (!m_ids.ContainsKey(agentID)) 317 if (!m_ids.ContainsKey(agentID))
342 m_ids.Add(agentID, rnd.Next(30000000)); 318 m_ids.Add(agentID, nrnd);
319 else
320 m_ids[agentID] = nrnd;
343 } 321 }
344 } 322 }
345 323
@@ -455,254 +433,7 @@ namespace OpenSim.Region.ClientStack.Linden
455 return responsedata; 433 return responsedata;
456 } 434 }
457 435
458// public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) 436
459// {
460// // TODO: this has to be redone to not busy-wait (and block the thread),
461// // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
462//
463//// if (m_log.IsDebugEnabled)
464//// {
465//// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
466//// foreach (object key in request.Keys)
467//// {
468//// debug += key.ToString() + "=" + request[key].ToString() + " ";
469//// }
470//// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
471//// }
472//
473// Queue<OSD> queue = TryGetQueue(agentID);
474// OSD element;
475//
476// lock (queue)
477// element = queue.Dequeue(); // 15s timeout
478//
479// Hashtable responsedata = new Hashtable();
480//
481// int thisID = 0;
482// lock (m_ids)
483// thisID = m_ids[agentID];
484//
485// if (element == null)
486// {
487// //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
488// if (thisID == -1) // close-request
489// {
490// m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
491// responsedata["int_response_code"] = 404; //501; //410; //404;
492// responsedata["content_type"] = "text/plain";
493// responsedata["keepalive"] = false;
494// responsedata["str_response_string"] = "Closed EQG";
495// return responsedata;
496// }
497// responsedata["int_response_code"] = 502;
498// responsedata["content_type"] = "text/plain";
499// responsedata["keepalive"] = false;
500// responsedata["str_response_string"] = "Upstream error: ";
501// responsedata["error_status_text"] = "Upstream error:";
502// responsedata["http_protocol_version"] = "HTTP/1.0";
503// return responsedata;
504// }
505//
506// OSDArray array = new OSDArray();
507// if (element == null) // didn't have an event in 15s
508// {
509// // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
510// array.Add(EventQueueHelper.KeepAliveEvent());
511// //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
512// }
513// else
514// {
515// array.Add(element);
516//
517// if (element is OSDMap)
518// {
519// OSDMap ev = (OSDMap)element;
520// m_log.DebugFormat(
521// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
522// ev["message"], m_scene.GetScenePresence(agentID).Name);
523// }
524//
525// lock (queue)
526// {
527// while (queue.Count > 0)
528// {
529// element = queue.Dequeue();
530//
531// if (element is OSDMap)
532// {
533// OSDMap ev = (OSDMap)element;
534// m_log.DebugFormat(
535// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
536// ev["message"], m_scene.GetScenePresence(agentID).Name);
537// }
538//
539// array.Add(element);
540// thisID++;
541// }
542// }
543// }
544//
545// OSDMap events = new OSDMap();
546// events.Add("events", array);
547//
548// events.Add("id", new OSDInteger(thisID));
549// lock (m_ids)
550// {
551// m_ids[agentID] = thisID + 1;
552// }
553//
554// responsedata["int_response_code"] = 200;
555// responsedata["content_type"] = "application/xml";
556// responsedata["keepalive"] = false;
557// responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
558//
559// m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
560//
561// return responsedata;
562// }
563
564// public Hashtable EventQueuePath2(Hashtable request)
565// {
566// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
567// // pull off the last "/" in the path.
568// Hashtable responsedata = new Hashtable();
569// capuuid = capuuid.Substring(0, capuuid.Length - 1);
570// capuuid = capuuid.Replace("/CAPS/EQG/", "");
571// UUID AvatarID = UUID.Zero;
572// UUID capUUID = UUID.Zero;
573//
574// // parse the path and search for the avatar with it registered
575// if (UUID.TryParse(capuuid, out capUUID))
576// {
577// lock (m_QueueUUIDAvatarMapping)
578// {
579// if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
580// {
581// AvatarID = m_QueueUUIDAvatarMapping[capUUID];
582// }
583// }
584//
585// if (AvatarID != UUID.Zero)
586// {
587// return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID));
588// }
589// else
590// {
591// responsedata["int_response_code"] = 404;
592// responsedata["content_type"] = "text/plain";
593// responsedata["keepalive"] = false;
594// responsedata["str_response_string"] = "Not Found";
595// responsedata["error_status_text"] = "Not Found";
596// responsedata["http_protocol_version"] = "HTTP/1.0";
597// return responsedata;
598// // return 404
599// }
600// }
601// else
602// {
603// responsedata["int_response_code"] = 404;
604// responsedata["content_type"] = "text/plain";
605// responsedata["keepalive"] = false;
606// responsedata["str_response_string"] = "Not Found";
607// responsedata["error_status_text"] = "Not Found";
608// responsedata["http_protocol_version"] = "HTTP/1.0";
609// return responsedata;
610// // return 404
611// }
612// }
613
614 public OSD EventQueueFallBack(string path, OSD request, string endpoint)
615 {
616 // This is a fallback element to keep the client from loosing EventQueueGet
617 // Why does CAPS fail sometimes!?
618 m_log.Warn("[EVENTQUEUE]: In the Fallback handler! We lost the Queue in the rest handler!");
619 string capuuid = path.Replace("/CAPS/EQG/","");
620 capuuid = capuuid.Substring(0, capuuid.Length - 1);
621
622// UUID AvatarID = UUID.Zero;
623 UUID capUUID = UUID.Zero;
624 if (UUID.TryParse(capuuid, out capUUID))
625 {
626/* Don't remove this yet code cleaners!
627 * Still testing this!
628 *
629 lock (m_QueueUUIDAvatarMapping)
630 {
631 if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
632 {
633 AvatarID = m_QueueUUIDAvatarMapping[capUUID];
634 }
635 }
636
637
638 if (AvatarID != UUID.Zero)
639 {
640 // Repair the CAP!
641 //OpenSim.Framework.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID);
642 //string capsBase = "/CAPS/EQG/";
643 //caps.RegisterHandler("EventQueueGet",
644 //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/",
645 //delegate(Hashtable m_dhttpMethod)
646 //{
647 // return ProcessQueue(m_dhttpMethod, AvatarID, caps);
648 //}));
649 // start new ID sequence.
650 Random rnd = new Random(System.Environment.TickCount);
651 lock (m_ids)
652 {
653 if (!m_ids.ContainsKey(AvatarID))
654 m_ids.Add(AvatarID, rnd.Next(30000000));
655 }
656
657
658 int thisID = 0;
659 lock (m_ids)
660 thisID = m_ids[AvatarID];
661
662 BlockingLLSDQueue queue = GetQueue(AvatarID);
663 OSDArray array = new OSDArray();
664 LLSD element = queue.Dequeue(15000); // 15s timeout
665 if (element == null)
666 {
667
668 array.Add(EventQueueHelper.KeepAliveEvent());
669 }
670 else
671 {
672 array.Add(element);
673 while (queue.Count() > 0)
674 {
675 array.Add(queue.Dequeue(1));
676 thisID++;
677 }
678 }
679 OSDMap events = new OSDMap();
680 events.Add("events", array);
681
682 events.Add("id", new LLSDInteger(thisID));
683
684 lock (m_ids)
685 {
686 m_ids[AvatarID] = thisID + 1;
687 }
688
689 return events;
690 }
691 else
692 {
693 return new LLSD();
694 }
695*
696*/
697 }
698 else
699 {
700 //return new LLSD();
701 }
702
703 return new OSDString("shutdown404!");
704 }
705
706 public void DisableSimulator(ulong handle, UUID avatarID) 437 public void DisableSimulator(ulong handle, UUID avatarID)
707 { 438 {
708 OSD item = EventQueueHelper.DisableSimulator(handle); 439 OSD item = EventQueueHelper.DisableSimulator(handle);