From 4854d779041e987ae13de4f30a37e4fab1b7a3d7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:09:20 +0200 Subject: [PATCH] Add an EventType enum and Type field to the poll service event args. This allows the manager to tell what type of event it is. All events except for lsl http in go to the "slow queue" which is run once per second as before. --- .../HttpServer/PollServiceEventArgs.cs | 8 ++++ .../HttpServer/PollServiceRequestManager.cs | 37 +++++++++++++------ .../Scripting/LSLHttp/UrlModule.cs | 8 ++-- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 2407533ab1..7c92a50155 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -45,6 +45,13 @@ namespace OpenSim.Framework.Servers.HttpServer public RequestMethod Request; public UUID Id; public int TimeOutms; + public EventType Type; + + public enum EventType : int + { + Normal = 0, + LslHttp = 1 + } public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, UUID pId, int pTimeOutms) { @@ -54,6 +61,7 @@ namespace OpenSim.Framework.Servers.HttpServer NoEvents = pNoEvents; Id = pId; TimeOutms = pTimeOutms; + Type = EventType.Normal; } } } diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 45b1375ff8..c7c7c13c94 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -174,13 +174,15 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_requests = new BlockingQueue(); - private static Queue m_retry_requests = new Queue(); + private BlockingQueue m_slowRequests = new BlockingQueue(); + private static Queue m_retryRequests = new Queue(); private uint m_WorkerThreadCount = 0; private Thread[] m_workerThreads; private Thread m_retrysThread; private bool m_running = true; + private int slowCount = 0; // private int m_timeout = 1000; // increase timeout 250; now use the event one @@ -195,7 +197,7 @@ namespace OpenSim.Framework.Servers.HttpServer { m_workerThreads[i] = Watchdog.StartThread( - poolWorkerJob, + PoolWorkerJob, String.Format("PollServiceWorkerThread{0}", i), ThreadPriority.Normal, false, @@ -217,15 +219,20 @@ namespace OpenSim.Framework.Servers.HttpServer { if (m_running) { - lock (m_retry_requests) - m_retry_requests.Enqueue(req); + lock (m_retryRequests) + m_retryRequests.Enqueue(req); } } public void Enqueue(PollServiceHttpRequest req) { if (m_running) - m_requests.Enqueue(req); + { + if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) + m_slowRequests.Enqueue(req); + else + m_requests.Enqueue(req); + } } private void CheckRetries() @@ -234,10 +241,18 @@ namespace OpenSim.Framework.Servers.HttpServer { Thread.Sleep(100); // let the world move .. back to faster rate Watchdog.UpdateThread(); - lock (m_retry_requests) + lock (m_retryRequests) { - while (m_retry_requests.Count > 0 && m_running) - Enqueue(m_retry_requests.Dequeue()); + while (m_retryRequests.Count > 0 && m_running) + m_requests.Enqueue(m_retryRequests.Dequeue()); + } + slowCount++; + if (slowCount >= 10) + { + slowCount = 0; + + while (m_slowRequests.Count() > 0 && m_running) + m_requests.Enqueue(m_retryRequests.Dequeue()); } } } @@ -261,7 +276,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { - foreach (PollServiceHttpRequest req in m_retry_requests) + foreach (PollServiceHttpRequest req in m_retryRequests) { m_server.DoHTTPGruntWork( req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), @@ -273,7 +288,7 @@ namespace OpenSim.Framework.Servers.HttpServer } PollServiceHttpRequest wreq; - m_retry_requests.Clear(); + m_retryRequests.Clear(); while (m_requests.Count() > 0) { @@ -294,7 +309,7 @@ namespace OpenSim.Framework.Servers.HttpServer // work threads - private void poolWorkerJob() + private void PoolWorkerJob() { PollServiceHttpRequest req; StreamReader str; diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index e93266c9e5..9c5596bbe3 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -172,9 +172,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string uri = "/lslhttp/" + urlcode.ToString(); - m_HttpServer.AddPollServiceHTTPHandler( - uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); + args.Type = PollServiceEventArgs.EventType.LslHttp; + m_HttpServer.AddPollServiceHTTPHandler(uri, args); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -422,7 +422,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) { - UrlData url = null; + UrlData url = null; RequestData requestData = null; lock (m_RequestMap) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fd8e586d37..58085946c4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7479,7 +7479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llSHA1String(string src) { m_host.AddScriptLPS(1); - return Util.SHA1Hash(src, Encoding.UTF8).ToUpper(); + return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); } protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve)