From 4854d779041e987ae13de4f30a37e4fab1b7a3d7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:09:20 +0200 Subject: [PATCH 1/4] 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) From bf292ce26f5742eaf1ae534320506b28f3a5492c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:24:15 +0200 Subject: [PATCH 2/4] Fix the boo-boo --- .../Servers/HttpServer/PollServiceRequestManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c7c7c13c94..06745f9b2b 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -229,9 +229,9 @@ namespace OpenSim.Framework.Servers.HttpServer if (m_running) { if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) - m_slowRequests.Enqueue(req); - else m_requests.Enqueue(req); + else + m_slowRequests.Enqueue(req); } } @@ -252,7 +252,7 @@ namespace OpenSim.Framework.Servers.HttpServer slowCount = 0; while (m_slowRequests.Count() > 0 && m_running) - m_requests.Enqueue(m_retryRequests.Dequeue()); + m_requests.Enqueue(m_slowRequests.Dequeue()); } } } From b8c2efa49c35d623a6a2969322536fde67cb86dc Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jul 2012 00:23:05 +0200 Subject: [PATCH 3/4] Convert the slow request queue into a regular queue and add some cleanup and locking. --- .../HttpServer/PollServiceRequestManager.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 06745f9b2b..6f87c85b8d 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -174,7 +174,7 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_requests = new BlockingQueue(); - private BlockingQueue m_slowRequests = new BlockingQueue(); + private static Queue m_slowRequests = new Queue(); private static Queue m_retryRequests = new Queue(); private uint m_WorkerThreadCount = 0; @@ -229,9 +229,14 @@ namespace OpenSim.Framework.Servers.HttpServer if (m_running) { if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) + { m_requests.Enqueue(req); + } else - m_slowRequests.Enqueue(req); + { + lock (m_slowRequests) + m_slowRequests.Enqueue(req); + } } } @@ -251,8 +256,11 @@ namespace OpenSim.Framework.Servers.HttpServer { slowCount = 0; - while (m_slowRequests.Count() > 0 && m_running) - m_requests.Enqueue(m_slowRequests.Dequeue()); + lock (m_slowRequests) + { + while (m_slowRequests.Count > 0 && m_running) + m_requests.Enqueue(m_slowRequests.Dequeue()); + } } } } @@ -290,6 +298,12 @@ namespace OpenSim.Framework.Servers.HttpServer PollServiceHttpRequest wreq; m_retryRequests.Clear(); + lock (m_slowRequests) + { + while (m_slowRequests.Count > 0 && m_running) + m_requests.Enqueue(m_slowRequests.Dequeue()); + } + while (m_requests.Count() > 0) { try From ba91d4ba93103f82876e0f2563c34aa6e4767392 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jul 2012 01:06:48 +0100 Subject: [PATCH 4/4] Changed GetTexture error code RequestedRangeNotSatisfiable to NotFound, since viewers don't seem to handle that and keep retrying --- OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 217217e25e..0797215b77 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -226,7 +226,9 @@ namespace OpenSim.Capabilities.Handlers // sending back the last byte instead of an error status if (start >= texture.Data.Length) { - response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; +// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; + // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters + response.StatusCode = (int)System.Net.HttpStatusCode.NotFound; } else {