From c99014991ba475943028c423190ba8fab3ada54f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 9 Apr 2020 13:41:41 +0100 Subject: [PATCH] cosmetics --- OpenSim/Capabilities/Caps.cs | 3 +- .../GetTexture/GetTextureRobustHandler.cs | 3 +- .../Servers/HttpServer/BaseHttpServer.cs | 6 ++-- .../HttpServer/PollServiceHttpRequest.cs | 3 +- .../HttpServer/WebsocketServerHandler.cs | 8 ++--- OpenSim/Framework/Util.cs | 2 ++ OpenSim/Region/Application/Application.cs | 1 - .../ClientStack/Linden/UDP/LLClientView.cs | 33 ++++++++----------- .../InstantMessage/InstantMessageModule.cs | 14 +++----- .../HttpRequest/ScriptsHttpRequests.cs | 8 ++--- .../Handlers/Map/MapAddServerConnector.cs | 3 +- .../Handlers/Map/MapRemoveServerConnector.cs | 3 +- .../Services/GridService/HypergridLinker.cs | 2 +- 13 files changed, 41 insertions(+), 48 deletions(-) diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs index 99319345f6..e8e577c7ba 100644 --- a/OpenSim/Capabilities/Caps.cs +++ b/OpenSim/Capabilities/Caps.cs @@ -125,7 +125,8 @@ namespace OpenSim.Framework.Capabilities None = 0, SentSeeds = 1, - ObjectAnim = 0x10 + ObjectAnim = 0x10, + AdvEnv = 0x20 } public CapsFlags Flags { get; set;} diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs index 2c1ba03ae1..10add50c50 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs @@ -32,6 +32,7 @@ using System.Drawing; using System.Drawing.Imaging; using System.Reflection; using System.IO; +using System.Net; using System.Web; using log4net; using Nini.Config; @@ -136,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers { string textureUrl = m_RedirectURL + "?texture_id=" + textureID.ToString(); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); - httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; + httpResponse.StatusCode = (int)HttpStatusCode.Moved; httpResponse.AddHeader("Location:", textureUrl); return true; } diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 188042df14..4f660f1383 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1703,7 +1703,7 @@ namespace OpenSim.Framework.Servers.HttpServer response.AddHeader("Access-Control-Allow-Origin", "*"); response.AddHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS"); response.AddHeader("Access-Control-Allow-Headers", "Content-Type"); - response.StatusCode = (int)OSHttpStatusCode.SuccessOk; + response.StatusCode = (int)HttpStatusCode.OK; return null; default: @@ -1948,7 +1948,7 @@ namespace OpenSim.Framework.Servers.HttpServer response.StatusCode = responsecode; - if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) + if (responsecode == (int)HttpStatusCode.Moved) { response.AddHeader("Location:", (string)responsedata["str_redirect_location"]); response.StatusCode = responsecode; @@ -2010,7 +2010,7 @@ namespace OpenSim.Framework.Servers.HttpServer public byte[] SendHTML500(OSHttpResponse response) { // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s - response.StatusCode = (int)OSHttpStatusCode.SuccessOk; + response.StatusCode = (int)HttpStatusCode.OK; response.AddHeader("Content-type", "text/html"); string responseString = GetHTTP500(); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 20eeb03b2f..e64bddb0a7 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Net; using System.Reflection; using System.Text; using OSHttpServer; @@ -132,7 +133,7 @@ namespace OpenSim.Framework.Servers.HttpServer response.StatusCode = responsecode; - if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) + if (responsecode == (int)HttpStatusCode.Moved) { response.AddHeader("Location:", (string)responsedata["str_redirect_location"]); response.KeepAlive = false; diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs index 6d9395710e..b1e5de4de7 100644 --- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs @@ -242,13 +242,13 @@ namespace OpenSim.Framework.Servers.HttpServer if (string.IsNullOrEmpty(_request.Headers["upgrade"])) { - FailUpgrade(OSHttpStatusCode.ClientErrorBadRequest, "no upgrade request submitted"); + FailUpgrade(HttpStatusCode.BadRequest, "no upgrade request submitted"); } string connectionheader = _request.Headers["upgrade"]; if (connectionheader.ToLower() != "websocket") { - FailUpgrade(OSHttpStatusCode.ClientErrorBadRequest, "no connection upgrade request submitted"); + FailUpgrade(HttpStatusCode.BadRequest, "no connection upgrade request submitted"); } // If the object consumer provided a method to validate the origin, we should call it and give the client a success or fail. @@ -266,7 +266,7 @@ namespace OpenSim.Framework.Servers.HttpServer } else { - FailUpgrade(OSHttpStatusCode.ClientErrorForbidden, "Origin Validation Failed"); + FailUpgrade(HttpStatusCode.Forbidden, "Origin Validation Failed"); } } else @@ -353,7 +353,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// /// HTTP Status reflecting the reason why /// Textual reason for the upgrade fail - private void FailUpgrade(OSHttpStatusCode pCode, string pMessage ) + private void FailUpgrade(HttpStatusCode pCode, string pMessage ) { string handshakeResponse = string.Format(HandshakeDeclineText, (int)pCode, pMessage.Replace("\n", string.Empty).Replace("\r", string.Empty)); byte[] bhandshakeResponse = Encoding.UTF8.GetBytes(handshakeResponse); diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index a12d17a47b..0e39661bb1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2667,6 +2667,8 @@ namespace OpenSim.Framework public static bool TryParseHttpRange(string header, out int start, out int end) { start = end = 0; + if(string.IsNullOrWhiteSpace(header)) + return false; if (header.StartsWith("bytes=")) { diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 8a32c6bdde..eed653ce4c 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -115,7 +115,6 @@ namespace OpenSim "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset"); } - // Verify the Threadpool allocates or uses enough worker and IO completion threads // .NET 2.0, workerthreads default to 50 * numcores // .NET 3.0, workerthreads defaults to 250 * numcores diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d58b6241f2..3fc327f2d5 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -750,8 +750,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (pprocessor.Async) { - object obj = new AsyncPacketProcess(pprocessor.method, packet); - m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj)); + m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => + { + try + { + pprocessor.method(packet); + } + catch (Exception e) + { + // Make sure that we see any exception caused by the asynchronous operation. + m_log.Error(string.Format( + "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packet, Name),e); + } + }); } else { @@ -762,24 +773,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - public void ProcessSpecificPacketAsync(object state) - { - AsyncPacketProcess packetObject = (AsyncPacketProcess)state; - - try - { - packetObject.Method(packetObject.Pack); - } - catch (Exception e) - { - // Make sure that we see any exception caused by the asynchronous operation. - m_log.Error( - string.Format( - "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packetObject.Pack, Name), - e); - } - } - #endregion Packet Handling # region Setup diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 71c0a8a63f..0383b0557f 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs @@ -75,14 +75,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; lock (m_scenes) - { - if (!m_scenes.Contains(scene)) - { - m_scenes.Add(scene); - scene.EventManager.OnClientConnect += OnClientConnect; - scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; - } - } + m_scenes.Add(scene); } public virtual void RegionLoaded(Scene scene) @@ -92,8 +85,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (m_TransferModule == null) { - m_TransferModule = - scene.RequestModuleInterface(); + m_TransferModule = scene.RequestModuleInterface(); if (m_TransferModule == null) { @@ -105,6 +97,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage m_enabled = false; } } + scene.EventManager.OnClientConnect += OnClientConnect; + scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; } public virtual void RemoveRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 83d91c40b5..f844248e12 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -708,7 +708,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } else { - Status = (int)OSHttpStatusCode.ClientErrorJoker; + Status = 499; //ClientErrorJoker; ResponseBody = e.Message; } } @@ -733,7 +733,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { if (Redirects >= MaxRedirects) { - Status = (int)OSHttpStatusCode.ClientErrorJoker; + Status = 499;//.ClientErrorJoker; ResponseBody = "Number of redirects exceeded max redirects"; WorkItem = null; RequestModule.GotCompletedRequest(this); @@ -744,14 +744,14 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest if (location == null) { - Status = (int)OSHttpStatusCode.ClientErrorJoker; + Status = 499;//ClientErrorJoker; ResponseBody = "HTTP redirect code but no location header"; WorkItem = null; RequestModule.GotCompletedRequest(this); } else if (!RequestModule.CheckAllowed(new Uri(location))) { - Status = (int)OSHttpStatusCode.ClientErrorJoker; + Status = 499;//ClientErrorJoker; ResponseBody = "URL from HTTP redirect blocked: " + location; WorkItem = null; RequestModule.GotCompletedRequest(this); diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 331dabf9a9..8a8652ee82 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Net; using System.Xml; using Nini.Config; @@ -115,7 +116,7 @@ namespace OpenSim.Server.Handlers.MapImage if (!request.ContainsKey("X") || !request.ContainsKey("Y") || !request.ContainsKey("DATA")) { - httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; + httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; return FailureResult("Bad request."); } int x = 0, y = 0; diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs index 9daeb73729..d894171928 100644 --- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Net; using System.Xml; using Nini.Config; @@ -113,7 +114,7 @@ namespace OpenSim.Server.Handlers.MapImage if (!request.ContainsKey("X") || !request.ContainsKey("Y")) { - httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; + httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; return FailureResult("Bad request."); } int x = 0, y = 0; diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index ae419f9db6..301456cec0 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -117,7 +117,7 @@ namespace OpenSim.Services.GridService for(int i = 0; i < alias.Length; ++i) { if(!string.IsNullOrWhiteSpace(alias[i])) - m_ThisGateKeeperAlias.Add(alias[i].ToLower()); + m_ThisGateKeeperAlias.Add(alias[i].Trim().ToLower()); } }