From bc9e4cfd961e6ed0184165e4f3cbb770b47a8dff Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Sep 2009 18:11:40 +0100 Subject: Add a RequestID (UUID.Random()) to the PollRequest and pass it to all even hander delegates. --- OpenSim/Framework/Console/RemoteConsole.cs | 10 +++++----- OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 6 +++--- OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | 3 +++ .../Framework/Servers/HttpServer/PollServiceRequestManager.cs | 2 +- .../Framework/Servers/HttpServer/PollServiceWorkerThread.cs | 6 +++--- .../CoreModules/Framework/EventQueue/EventQueueGetModule.cs | 8 ++++---- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 5a18b94..76276a5 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -370,7 +370,7 @@ namespace OpenSim.Framework.Console } } - private bool HasEvents(UUID sessionID) + private bool HasEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; @@ -386,19 +386,19 @@ namespace OpenSim.Framework.Console return false; } - private Hashtable GetEvents(UUID sessionID, string request) + private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request) { ConsoleConnection c = null; lock (m_Connections) { if (!m_Connections.ContainsKey(sessionID)) - return NoEvents(UUID.Zero); + return NoEvents(RequestID, UUID.Zero); c = m_Connections[sessionID]; } c.last = System.Environment.TickCount; if (c.lastLineSeen >= m_LineNumber) - return NoEvents(UUID.Zero); + return NoEvents(RequestID, UUID.Zero); Hashtable result = new Hashtable(); @@ -440,7 +440,7 @@ namespace OpenSim.Framework.Console return result; } - private Hashtable NoEvents(UUID id) + private Hashtable NoEvents(UUID RequestID, UUID id) { Hashtable result = new Hashtable(); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index ed387d1..61cb8aa 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -30,11 +30,11 @@ using System.Collections; using OpenMetaverse; namespace OpenSim.Framework.Servers.HttpServer { - public delegate bool HasEventsMethod(UUID pId); + public delegate bool HasEventsMethod(UUID requestID, UUID pId); - public delegate Hashtable GetEventsMethod(UUID pId, string request); + public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); - public delegate Hashtable NoEventsMethod(UUID pId); + public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); public class PollServiceEventArgs : EventArgs { diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index ff7c1e8..553a7eb 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs @@ -27,6 +27,7 @@ using System; using HttpServer; +using OpenMetaverse; namespace OpenSim.Framework.Servers.HttpServer { @@ -37,12 +38,14 @@ namespace OpenSim.Framework.Servers.HttpServer public readonly IHttpClientContext HttpContext; public readonly IHttpRequest Request; public readonly int RequestTime; + public readonly UUID RequestID; public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; HttpContext = pHttpContext; Request = pRequest; RequestTime = System.Environment.TickCount; + RequestID = UUID.Random(); } } } diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index db80f1d..1c54581 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -130,7 +130,7 @@ namespace OpenSim.Framework.Servers.HttpServer foreach (object o in m_requests) { PollServiceHttpRequest req = (PollServiceHttpRequest) o; - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); } m_requests.Clear(); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index 1e8706c..ce32443 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs @@ -100,11 +100,11 @@ namespace OpenSim.Framework.Servers.HttpServer PollServiceHttpRequest req = m_request.Dequeue(); try { - if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id)) + if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { StreamReader str = new StreamReader(req.Request.Body); - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); m_server.DoHTTPGruntWork(responsedata, new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); } @@ -112,7 +112,7 @@ namespace OpenSim.Framework.Servers.HttpServer { if ((Environment.TickCount - req.RequestTime) > m_timeout) { - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.PollServiceArgs.Id), + m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); } else diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs index 26eed42..55ea4b7 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs @@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue } } - public bool HasEvents(UUID agentID) + public bool HasEvents(UUID requestID, UUID agentID) { // Don't use this, because of race conditions at agent closing time //Queue queue = TryGetQueue(agentID); @@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue return false; } - public Hashtable GetEvents(UUID pAgentId, string request) + public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { Queue queue = TryGetQueue(pAgentId); OSD element; lock (queue) { if (queue.Count == 0) - return NoEvents(pAgentId); + return NoEvents(requestID, pAgentId); element = queue.Dequeue(); // 15s timeout } @@ -398,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); } - public Hashtable NoEvents(UUID agentID) + public Hashtable NoEvents(UUID requestID, UUID agentID) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 502; -- cgit v1.1