From 0174e326e3680ebc76dbd525191ad9b07634ec6d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 24 Nov 2011 20:27:11 +0000
Subject: Add a "debug eq" console command for debugging.
This will log outgoing event queue message names if turned on.
---
.../Linden/Caps/EventQueue/EventQueueGetModule.cs | 85 ++++++++++++++++++++--
1 file changed, 79 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 7d73b3e..f5feb71 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -39,6 +39,7 @@ using OpenMetaverse.Messages.Linden;
using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@@ -58,9 +59,15 @@ namespace OpenSim.Region.ClientStack.Linden
public class EventQueueGetModule : IEventQueue, IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- protected Scene m_scene = null;
+
+ ///
+ /// Debug level.
+ ///
+ public int DebugLevel { get; set; }
+
+ protected Scene m_scene;
private IConfigSource m_gConfig;
- bool enabledYN = false;
+ bool enabledYN;
private Dictionary m_ids = new Dictionary();
@@ -97,6 +104,15 @@ namespace OpenSim.Region.ClientStack.Linden
scene.EventManager.OnClientClosed += ClientClosed;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
+
+ MainConsole.Instance.Commands.AddCommand(
+ "event queue",
+ false,
+ "debug eq",
+ "debug eq [0|1]",
+ "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n"
+ + "debug eq 1 will turn off event queue debugging.",
+ HandleDebugEq);
}
else
{
@@ -128,6 +144,22 @@ namespace OpenSim.Region.ClientStack.Linden
}
#endregion
+ protected void HandleDebugEq(string module, string[] args)
+ {
+ int debugLevel;
+
+ if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel)))
+ {
+ MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]");
+ }
+ else
+ {
+ DebugLevel = debugLevel;
+ MainConsole.Instance.OutputFormat(
+ "Set event queue debug level to {0} in {1}", DebugLevel, m_scene.RegionInfo.RegionName);
+ }
+ }
+
///
/// Always returns a valid queue
///
@@ -323,7 +355,9 @@ namespace OpenSim.Region.ClientStack.Linden
// This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler(
- capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
+ capsBase + EventQueueGetUUID.ToString() + "/",
+ EventQueuePoll,
+ new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
Random rnd = new Random(Environment.TickCount);
lock (m_ids)
@@ -370,12 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
+ if (DebugLevel > 0 && element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(pAgentId).Name);
+ }
+
array.Add(element);
+
lock (queue)
{
while (queue.Count > 0)
{
- array.Add(queue.Dequeue());
+ element = queue.Dequeue();
+
+ if (DebugLevel > 0 && element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(pAgentId).Name);
+ }
+
+ array.Add(element);
thisID++;
}
}
@@ -471,11 +524,29 @@ namespace OpenSim.Region.ClientStack.Linden
{
array.Add(element);
+ if (element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(agentID).Name);
+ }
+
lock (queue)
{
while (queue.Count > 0)
{
- array.Add(queue.Dequeue());
+ element = queue.Dequeue();
+
+ if (element is OSDMap)
+ {
+ OSDMap ev = (OSDMap)element;
+ m_log.DebugFormat(
+ "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+ ev["message"], m_scene.GetScenePresence(agentID).Name);
+ }
+
+ array.Add(element);
thisID++;
}
}
@@ -494,7 +565,8 @@ namespace OpenSim.Region.ClientStack.Linden
responsedata["content_type"] = "application/xml";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
- //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
+
+ m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
return responsedata;
}
@@ -717,6 +789,7 @@ namespace OpenSim.Region.ClientStack.Linden
OSD item = EventQueueHelper.GroupMembership(groupUpdate);
Enqueue(item, avatarID);
}
+
public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID)
{
OSD item = EventQueueHelper.PlacesQuery(groupUpdate);
--
cgit v1.1
From 63c137820b44e9d1e248ba32ccd6df5110a2bdb9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 24 Nov 2011 21:27:35 +0000
Subject: Stop passing a request handler to the initial caps.RegisterHandler in
EventQueueGetModule since this is immediatley replaced by a poll server
handler.
This allows us to comment out a bunch of code and simplify the codebase and readability.
---
.../Linden/Caps/EventQueue/EventQueueGetModule.cs | 319 +++++++++++----------
1 file changed, 162 insertions(+), 157 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index f5feb71..24f76d69 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -346,12 +346,16 @@ namespace OpenSim.Region.ClientStack.Linden
}
// Register this as a caps handler
+ // FIXME: Confusingly, we need to register separate as a capability so that the client is told about
+ // EventQueueGet when it receive capability information, but then we replace the rest handler immediately
+ // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but
+ // really it should be possible to directly register the poll handler as a capability.
caps.RegisterHandler("EventQueueGet",
- new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/",
- delegate(Hashtable m_dhttpMethod)
- {
- return ProcessQueue(m_dhttpMethod, agentID, caps);
- }));
+ new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", null));
+// delegate(Hashtable m_dhttpMethod)
+// {
+// return ProcessQueue(m_dhttpMethod, agentID, caps);
+// }));
// This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler(
@@ -382,6 +386,8 @@ namespace OpenSim.Region.ClientStack.Linden
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
{
+ m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId);
+
Queue queue = TryGetQueue(pAgentId);
OSD element;
lock (queue)
@@ -465,167 +471,166 @@ namespace OpenSim.Region.ClientStack.Linden
return responsedata;
}
- public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps)
- {
- // TODO: this has to be redone to not busy-wait (and block the thread),
- // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
-
-// if (m_log.IsDebugEnabled)
-// {
-// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
-// foreach (object key in request.Keys)
+// public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps)
+// {
+// // TODO: this has to be redone to not busy-wait (and block the thread),
+// // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
+//
+//// if (m_log.IsDebugEnabled)
+//// {
+//// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
+//// foreach (object key in request.Keys)
+//// {
+//// debug += key.ToString() + "=" + request[key].ToString() + " ";
+//// }
+//// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
+//// }
+//
+// Queue queue = TryGetQueue(agentID);
+// OSD element;
+//
+// lock (queue)
+// element = queue.Dequeue(); // 15s timeout
+//
+// Hashtable responsedata = new Hashtable();
+//
+// int thisID = 0;
+// lock (m_ids)
+// thisID = m_ids[agentID];
+//
+// if (element == null)
+// {
+// //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
+// if (thisID == -1) // close-request
// {
-// debug += key.ToString() + "=" + request[key].ToString() + " ";
+// m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
+// responsedata["int_response_code"] = 404; //501; //410; //404;
+// responsedata["content_type"] = "text/plain";
+// responsedata["keepalive"] = false;
+// responsedata["str_response_string"] = "Closed EQG";
+// return responsedata;
// }
-// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
+// responsedata["int_response_code"] = 502;
+// responsedata["content_type"] = "text/plain";
+// responsedata["keepalive"] = false;
+// responsedata["str_response_string"] = "Upstream error: ";
+// responsedata["error_status_text"] = "Upstream error:";
+// responsedata["http_protocol_version"] = "HTTP/1.0";
+// return responsedata;
// }
-
- Queue queue = TryGetQueue(agentID);
- OSD element;
-
- lock (queue)
- element = queue.Dequeue(); // 15s timeout
-
- Hashtable responsedata = new Hashtable();
-
- int thisID = 0;
- lock (m_ids)
- thisID = m_ids[agentID];
-
- if (element == null)
- {
- //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
- if (thisID == -1) // close-request
- {
- m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
- responsedata["int_response_code"] = 404; //501; //410; //404;
- responsedata["content_type"] = "text/plain";
- responsedata["keepalive"] = false;
- responsedata["str_response_string"] = "Closed EQG";
- return responsedata;
- }
- responsedata["int_response_code"] = 502;
- responsedata["content_type"] = "text/plain";
- responsedata["keepalive"] = false;
- responsedata["str_response_string"] = "Upstream error: ";
- responsedata["error_status_text"] = "Upstream error:";
- responsedata["http_protocol_version"] = "HTTP/1.0";
- return responsedata;
- }
-
- OSDArray array = new OSDArray();
- if (element == null) // didn't have an event in 15s
- {
- // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
- array.Add(EventQueueHelper.KeepAliveEvent());
- //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
- }
- else
- {
- array.Add(element);
-
- if (element is OSDMap)
- {
- OSDMap ev = (OSDMap)element;
- m_log.DebugFormat(
- "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
- ev["message"], m_scene.GetScenePresence(agentID).Name);
- }
-
- lock (queue)
- {
- while (queue.Count > 0)
- {
- element = queue.Dequeue();
-
- if (element is OSDMap)
- {
- OSDMap ev = (OSDMap)element;
- m_log.DebugFormat(
- "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
- ev["message"], m_scene.GetScenePresence(agentID).Name);
- }
-
- array.Add(element);
- thisID++;
- }
- }
- }
-
- OSDMap events = new OSDMap();
- events.Add("events", array);
-
- events.Add("id", new OSDInteger(thisID));
- lock (m_ids)
- {
- m_ids[agentID] = thisID + 1;
- }
-
- responsedata["int_response_code"] = 200;
- responsedata["content_type"] = "application/xml";
- responsedata["keepalive"] = false;
- responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
-
- m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
-
- return responsedata;
- }
+//
+// OSDArray array = new OSDArray();
+// if (element == null) // didn't have an event in 15s
+// {
+// // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
+// array.Add(EventQueueHelper.KeepAliveEvent());
+// //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
+// }
+// else
+// {
+// array.Add(element);
+//
+// if (element is OSDMap)
+// {
+// OSDMap ev = (OSDMap)element;
+// m_log.DebugFormat(
+// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+// ev["message"], m_scene.GetScenePresence(agentID).Name);
+// }
+//
+// lock (queue)
+// {
+// while (queue.Count > 0)
+// {
+// element = queue.Dequeue();
+//
+// if (element is OSDMap)
+// {
+// OSDMap ev = (OSDMap)element;
+// m_log.DebugFormat(
+// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
+// ev["message"], m_scene.GetScenePresence(agentID).Name);
+// }
+//
+// array.Add(element);
+// thisID++;
+// }
+// }
+// }
+//
+// OSDMap events = new OSDMap();
+// events.Add("events", array);
+//
+// events.Add("id", new OSDInteger(thisID));
+// lock (m_ids)
+// {
+// m_ids[agentID] = thisID + 1;
+// }
+//
+// responsedata["int_response_code"] = 200;
+// responsedata["content_type"] = "application/xml";
+// responsedata["keepalive"] = false;
+// responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
+//
+// m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
+//
+// return responsedata;
+// }
public Hashtable EventQueuePoll(Hashtable request)
{
return new Hashtable();
}
- public Hashtable EventQueuePath2(Hashtable request)
- {
- string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
- // pull off the last "/" in the path.
- Hashtable responsedata = new Hashtable();
- capuuid = capuuid.Substring(0, capuuid.Length - 1);
- capuuid = capuuid.Replace("/CAPS/EQG/", "");
- UUID AvatarID = UUID.Zero;
- UUID capUUID = UUID.Zero;
-
- // parse the path and search for the avatar with it registered
- if (UUID.TryParse(capuuid, out capUUID))
- {
- lock (m_QueueUUIDAvatarMapping)
- {
- if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
- {
- AvatarID = m_QueueUUIDAvatarMapping[capUUID];
- }
- }
-
- if (AvatarID != UUID.Zero)
- {
- return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID));
- }
- else
- {
- responsedata["int_response_code"] = 404;
- responsedata["content_type"] = "text/plain";
- responsedata["keepalive"] = false;
- responsedata["str_response_string"] = "Not Found";
- responsedata["error_status_text"] = "Not Found";
- responsedata["http_protocol_version"] = "HTTP/1.0";
- return responsedata;
- // return 404
- }
- }
- else
- {
- responsedata["int_response_code"] = 404;
- responsedata["content_type"] = "text/plain";
- responsedata["keepalive"] = false;
- responsedata["str_response_string"] = "Not Found";
- responsedata["error_status_text"] = "Not Found";
- responsedata["http_protocol_version"] = "HTTP/1.0";
- return responsedata;
- // return 404
- }
-
- }
+// public Hashtable EventQueuePath2(Hashtable request)
+// {
+// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
+// // pull off the last "/" in the path.
+// Hashtable responsedata = new Hashtable();
+// capuuid = capuuid.Substring(0, capuuid.Length - 1);
+// capuuid = capuuid.Replace("/CAPS/EQG/", "");
+// UUID AvatarID = UUID.Zero;
+// UUID capUUID = UUID.Zero;
+//
+// // parse the path and search for the avatar with it registered
+// if (UUID.TryParse(capuuid, out capUUID))
+// {
+// lock (m_QueueUUIDAvatarMapping)
+// {
+// if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
+// {
+// AvatarID = m_QueueUUIDAvatarMapping[capUUID];
+// }
+// }
+//
+// if (AvatarID != UUID.Zero)
+// {
+// return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID));
+// }
+// else
+// {
+// responsedata["int_response_code"] = 404;
+// responsedata["content_type"] = "text/plain";
+// responsedata["keepalive"] = false;
+// responsedata["str_response_string"] = "Not Found";
+// responsedata["error_status_text"] = "Not Found";
+// responsedata["http_protocol_version"] = "HTTP/1.0";
+// return responsedata;
+// // return 404
+// }
+// }
+// else
+// {
+// responsedata["int_response_code"] = 404;
+// responsedata["content_type"] = "text/plain";
+// responsedata["keepalive"] = false;
+// responsedata["str_response_string"] = "Not Found";
+// responsedata["error_status_text"] = "Not Found";
+// responsedata["http_protocol_version"] = "HTTP/1.0";
+// return responsedata;
+// // return 404
+// }
+// }
public OSD EventQueueFallBack(string path, OSD request, string endpoint)
{
--
cgit v1.1
From 0a60e9537f2a1aa30fd1d9c23ada5bf1fcfed889 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 24 Nov 2011 21:30:40 +0000
Subject: comment out a noisy log line I accidentally left in from the last
commit
---
.../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 24f76d69..5c721d4 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -386,7 +386,7 @@ namespace OpenSim.Region.ClientStack.Linden
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
{
- m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId);
+// m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId);
Queue queue = TryGetQueue(pAgentId);
OSD element;
--
cgit v1.1