From 15d5f3d09d140a0850d968fd3b738afc0b1f3985 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 4 Sep 2012 00:11:14 +0100 Subject: Bump master code up to 0.7.5 now that 0.7.4 is out. --- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 5f01788..c9d9770 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,7 +29,7 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.7.4"; + private const string VERSION_NUMBER = "0.7.5"; private const Flavour VERSION_FLAVOUR = Flavour.Dev; public enum Flavour -- cgit v1.1 From 25111e703f54d84c7c51e32db1f94332ea3ffd00 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 11 Sep 2012 21:48:02 +0100 Subject: Add levels 4 and 5 to "debug http" console command that will log a sample of incoming request data and the entire incoming data respectively. See "help debug http" for more details. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 68 ++++++++++++++++++---- OpenSim/Framework/Servers/MainServer.cs | 2 + 2 files changed, 58 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index f57ea76..c81e283 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -449,9 +449,7 @@ namespace OpenSim.Framework.Servers.HttpServer if (TryGetStreamHandler(handlerKey, out requestHandler)) { if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", - request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); + LogIncomingToStreamHandler(request, requestHandler); response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. @@ -563,9 +561,7 @@ namespace OpenSim.Framework.Servers.HttpServer if (DoWeHaveALLSDHandler(request.RawUrl)) { if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + LogIncomingToContentTypeHandler(request); buffer = HandleLLSDRequests(request, response); } @@ -573,18 +569,14 @@ namespace OpenSim.Framework.Servers.HttpServer else if (DoWeHaveAHTTPHandler(request.RawUrl)) { if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + LogIncomingToContentTypeHandler(request); buffer = HandleHTTPRequest(request, response); } else { if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", - request.HttpMethod, request.Url.PathAndQuery); + LogIncomingToXmlRpcHandler(request); // generic login request. buffer = HandleXmlRpcRequests(request, response); @@ -654,6 +646,58 @@ namespace OpenSim.Framework.Servers.HttpServer } } + private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) + { + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", + request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); + + if (DebugLevel >= 4) + LogIncomingInDetail(request); + } + + private void LogIncomingToContentTypeHandler(OSHttpRequest request) + { + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + + if (DebugLevel >= 4) + LogIncomingInDetail(request); + } + + private void LogIncomingToXmlRpcHandler(OSHttpRequest request) + { + m_log.DebugFormat( + "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); + + if (DebugLevel >= 4) + LogIncomingInDetail(request); + } + + private void LogIncomingInDetail(OSHttpRequest request) + { + using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8)) + { + string output; + + if (DebugLevel == 4) + { + const int sampleLength = 80; + char[] sampleChars = new char[sampleLength]; + reader.Read(sampleChars, 0, sampleLength); + output = string.Format("[BASE HTTP SERVER]: {0}...", sampleChars); + } + else + { + output = string.Format("[BASE HTTP SERVER]: {0}", reader.ReadToEnd()); + } + + m_log.Debug(output); + } + } + private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) { string bestMatch = null; diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 8dc0e3a..1ac0953 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -111,6 +111,8 @@ namespace OpenSim.Framework.Servers + "If level >= 1, then short warnings are logged when receiving bad input data.\n" + "If level >= 2, then long warnings are logged when receiving bad input data.\n" + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" + + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" + + "If level >= 5, then the entire incoming data is logged.\n" + "If no level is specified then the current level is returned.", HandleDebugHttpCommand); } -- cgit v1.1 From d53a53d4c599e77f039149128526ac67570b30fb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Sep 2012 00:10:48 +0100 Subject: Make "show http-handlers" command available for ROBUST instances as well as the simulator executable. --- OpenSim/Framework/Servers/MainServer.cs | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 1ac0953..b367b12 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Net; +using System.Text; using log4net; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -105,6 +106,11 @@ namespace OpenSim.Framework.Servers public static void RegisterHttpConsoleCommands(ICommandConsole console) { console.Commands.AddCommand( + "Comms", false, "show http-handlers", + "show http-handlers", + "Show all registered http handlers", HandleShowHttpHandlersCommand); + + console.Commands.AddCommand( "Debug", false, "debug http", "debug http []", "Turn on inbound non-poll http request debugging.", "If level <= 0, then no extra logging is done.\n" @@ -142,6 +148,51 @@ namespace OpenSim.Framework.Servers } } + private static void HandleShowHttpHandlersCommand(string module, string[] args) + { + if (args.Length != 2) + { + MainConsole.Instance.Output("Usage: show http-handlers"); + return; + } + + StringBuilder handlers = new StringBuilder(); + + lock (m_Servers) + { + foreach (BaseHttpServer httpServer in m_Servers.Values) + { + handlers.AppendFormat( + "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); + + handlers.AppendFormat("* XMLRPC:\n"); + foreach (String s in httpServer.GetXmlRpcHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* HTTP:\n"); + List poll = httpServer.GetPollServiceHandlerKeys(); + foreach (String s in httpServer.GetHTTPHandlerKeys()) + handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); + + handlers.AppendFormat("* Agent:\n"); + foreach (String s in httpServer.GetAgentHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* LLSD:\n"); + foreach (String s in httpServer.GetLLSDHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); + foreach (String s in httpServer.GetStreamHandlerKeys()) + handlers.AppendFormat("\t{0}\n", s); + + handlers.Append("\n"); + } + } + + MainConsole.Instance.Output(handlers.ToString()); + } + /// /// Register an already started HTTP server to the collection of known servers. /// -- cgit v1.1 From 7df7b86ec5e6186fc86dd075792f56001cac66f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Sep 2012 23:01:07 +0100 Subject: Fix bug in logging sample input at debug http level 4. Also converts newlines to "\n" text. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index c81e283..43a19fa 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -687,7 +687,7 @@ namespace OpenSim.Framework.Servers.HttpServer const int sampleLength = 80; char[] sampleChars = new char[sampleLength]; reader.Read(sampleChars, 0, sampleLength); - output = string.Format("[BASE HTTP SERVER]: {0}...", sampleChars); + output = string.Format("[BASE HTTP SERVER]: {0}...", new string(sampleChars).Replace("\n", @"\n")); } else { -- cgit v1.1 From cdc3781f42869586aa4bba482359f8cda21cb912 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Sep 2012 23:02:25 +0100 Subject: Fix usage statement on "debug http" console command since max level is now 5 rather than 3 --- OpenSim/Framework/Servers/MainServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index b367b12..7402c73 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -144,7 +144,7 @@ namespace OpenSim.Framework.Servers } else { - MainConsole.Instance.Output("Usage: debug http 0..3"); + MainConsole.Instance.Output("Usage: debug http 0..5"); } } -- cgit v1.1 From 387a1bb283c0c55178421f2c28b0d28a24dac7a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 20 Sep 2012 22:36:47 +0100 Subject: Add ability to turn on/off logging of outgoing HTTP requests flowing through WebUtil. This is for debugging purposes. This is controlled via the "debug http" command which can already log incoming requests. This now gains a mandatory parameter of in, out or all to control what is logged. Log messages are also shortened and labelled and HTTP IN or HTTP OUT to be consistent with existing UDP PACKET IN and PACKET OUT messages. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 10 +-- OpenSim/Framework/Servers/MainServer.cs | 87 ++++++++++++++++------ 2 files changed, 70 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 43a19fa..f93b3dd 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -529,7 +529,7 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleHTTPRequest(request, response); @@ -541,7 +541,7 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleLLSDRequests(request, response); @@ -649,7 +649,7 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) { m_log.DebugFormat( - "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", + "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3}", request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); if (DebugLevel >= 4) @@ -659,7 +659,7 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToContentTypeHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", request.ContentType, request.HttpMethod, request.Url.PathAndQuery); if (DebugLevel >= 4) @@ -669,7 +669,7 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToXmlRpcHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", + "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1}", request.HttpMethod, request.Url.PathAndQuery); if (DebugLevel >= 4) diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 7402c73..b7a133e 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -48,9 +48,11 @@ namespace OpenSim.Framework.Servers /// Control the printing of certain debug messages. /// /// - /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. - /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. - /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. + /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. + /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. + /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. + /// If DebugLevel >= 4 then the start of the body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 5 then the entire body of incoming non-poll HTTP requests will be logged. /// public static int DebugLevel { @@ -102,7 +104,6 @@ namespace OpenSim.Framework.Servers get { return new Dictionary(m_Servers); } } - public static void RegisterHttpConsoleCommands(ICommandConsole console) { console.Commands.AddCommand( @@ -111,15 +112,18 @@ namespace OpenSim.Framework.Servers "Show all registered http handlers", HandleShowHttpHandlersCommand); console.Commands.AddCommand( - "Debug", false, "debug http", "debug http []", - "Turn on inbound non-poll http request debugging.", - "If level <= 0, then no extra logging is done.\n" - + "If level >= 1, then short warnings are logged when receiving bad input data.\n" - + "If level >= 2, then long warnings are logged when receiving bad input data.\n" - + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" - + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" - + "If level >= 5, then the entire incoming data is logged.\n" - + "If no level is specified then the current level is returned.", + "Debug", false, "debug http", "debug http []", + "Turn on http request logging.", + "If in or all and\n" + + " level <= 0, then no extra logging is done.\n" + + " level >= 1, then short warnings are logged when receiving bad input data.\n" + + " level >= 2, then long warnings are logged when receiving bad input data.\n" + + " level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" + + " level >= 4, then a sample from the beginning of the incoming data is logged.\n" + + " level >= 5, then the entire incoming data is logged.\n" + + " no level is specified then the current level is returned.\n\n" + + "If out or all and\n" + + " level >= 3. then short notices about all outgoing requests going through WebUtil are logged.\n", HandleDebugHttpCommand); } @@ -127,24 +131,63 @@ namespace OpenSim.Framework.Servers /// Turn on some debugging values for OpenSim. /// /// - private static void HandleDebugHttpCommand(string module, string[] args) + private static void HandleDebugHttpCommand(string module, string[] cmdparams) { - if (args.Length == 3) + if (cmdparams.Length < 3) { + MainConsole.Instance.Output("Usage: debug http 0..5"); + return; + } + + bool inReqs = false; + bool outReqs = false; + bool allReqs = false; + + string subCommand = cmdparams[2]; + + if (subCommand == "in") + inReqs = true; + else if (subCommand == "out") + outReqs = true; + else + allReqs = true; + + if (cmdparams.Length >= 4) + { + string rawNewDebug = cmdparams[3]; int newDebug; - if (int.TryParse(args[2], out newDebug)) + + if (!int.TryParse(rawNewDebug, out newDebug)) + { + MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); + return; + } + + if (newDebug < 0 || newDebug > 5) + { + MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug); + return; + } + + if (allReqs || inReqs) { MainServer.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("In debug level set to {0}", newDebug); + } + + if (allReqs || outReqs) + { + WebUtil.DebugLevel = newDebug; + MainConsole.Instance.OutputFormat("Out debug level set to {0}", newDebug); } - } - else if (args.Length == 2) - { - MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); } else { - MainConsole.Instance.Output("Usage: debug http 0..5"); + if (allReqs || inReqs) + MainConsole.Instance.OutputFormat("Current in debug level is {0}", MainServer.DebugLevel); + + if (allReqs || outReqs) + MainConsole.Instance.OutputFormat("Current out debug level is {0}", WebUtil.DebugLevel); } } -- cgit v1.1 From a5b3989e5db0a3b22e44b84412227a8e487bcef2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 20 Sep 2012 23:18:19 +0100 Subject: Insert a new log level 4 for HTTP IN and HTTP OUT that will log how long the request took. This is only printed if debug http level >= 4 and the request didn't take more than the time considered 'long', in which case the existing log message is printed. This displaces the previous log levels 4 and 5 which are now 5 and 6 respectively. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 47 ++++++++++++++------- OpenSim/Framework/Servers/MainServer.cs | 48 ++++++++++++++-------- 2 files changed, 63 insertions(+), 32 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index f93b3dd..4e04dd8 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -54,6 +54,12 @@ namespace OpenSim.Framework.Servers.HttpServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); + /// + /// Gets or sets the debug level. + /// + /// + /// See MainServer.DebugLevel. + /// public int DebugLevel { get; set; } private volatile int NotSocketErrors = 0; @@ -529,8 +535,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); buffer = HandleHTTPRequest(request, response); break; @@ -541,8 +547,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); buffer = HandleLLSDRequests(request, response); break; @@ -640,7 +646,18 @@ namespace OpenSim.Framework.Servers.HttpServer uriString, requestHandler != null ? requestHandler.Name : "", requestHandler != null ? requestHandler.Description : "", - request.RemoteIPEndPoint.ToString(), + request.RemoteIPEndPoint, + tickdiff); + } + else if (DebugLevel >= 4) + { + m_log.DebugFormat( + "[BASE HTTP SERVER]: HTTP IN {0} {1} {2} {3} from {4} took {5}ms", + requestMethod, + uriString, + requestHandler != null ? requestHandler.Name : "", + requestHandler != null ? requestHandler.Description : "", + request.RemoteIPEndPoint, tickdiff); } } @@ -649,30 +666,30 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3}", - request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); + "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3} from {4}", + request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description, request.RemoteIPEndPoint); - if (DebugLevel >= 4) + if (DebugLevel >= 5) LogIncomingInDetail(request); } private void LogIncomingToContentTypeHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery); + "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); - if (DebugLevel >= 4) + if (DebugLevel >= 5) LogIncomingInDetail(request); } private void LogIncomingToXmlRpcHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1}", - request.HttpMethod, request.Url.PathAndQuery); + "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1} from {2}", + request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); - if (DebugLevel >= 4) + if (DebugLevel >= 5) LogIncomingInDetail(request); } @@ -682,7 +699,7 @@ namespace OpenSim.Framework.Servers.HttpServer { string output; - if (DebugLevel == 4) + if (DebugLevel == 5) { const int sampleLength = 80; char[] sampleChars = new char[sampleLength]; diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index b7a133e..72f9cce 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -51,8 +51,9 @@ namespace OpenSim.Framework.Servers /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. - /// If DebugLevel >= 4 then the start of the body of incoming non-poll HTTP requests will be logged. - /// If DebugLevel >= 5 then the entire body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. + /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. /// public static int DebugLevel { @@ -115,15 +116,17 @@ namespace OpenSim.Framework.Servers "Debug", false, "debug http", "debug http []", "Turn on http request logging.", "If in or all and\n" - + " level <= 0, then no extra logging is done.\n" - + " level >= 1, then short warnings are logged when receiving bad input data.\n" - + " level >= 2, then long warnings are logged when receiving bad input data.\n" - + " level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" - + " level >= 4, then a sample from the beginning of the incoming data is logged.\n" - + " level >= 5, then the entire incoming data is logged.\n" + + " level <= 0 then no extra logging is done.\n" + + " level >= 1 then short warnings are logged when receiving bad input data.\n" + + " level >= 2 then long warnings are logged when receiving bad input data.\n" + + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" + + " level >= 4 then the time taken to fulfill the request is logged.\n" + + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" + + " level >= 6 then the entire incoming data is logged.\n" + " no level is specified then the current level is returned.\n\n" + "If out or all and\n" - + " level >= 3. then short notices about all outgoing requests going through WebUtil are logged.\n", + + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" + + " level >= 4 then the time taken to fulfill the request is logged.\n", HandleDebugHttpCommand); } @@ -135,7 +138,7 @@ namespace OpenSim.Framework.Servers { if (cmdparams.Length < 3) { - MainConsole.Instance.Output("Usage: debug http 0..5"); + MainConsole.Instance.Output("Usage: debug http 0..6"); return; } @@ -145,12 +148,23 @@ namespace OpenSim.Framework.Servers string subCommand = cmdparams[2]; - if (subCommand == "in") + if (subCommand.ToLower() == "in") + { inReqs = true; - else if (subCommand == "out") + } + else if (subCommand.ToLower() == "out") + { outReqs = true; - else + } + else if (subCommand.ToLower() == "all") + { allReqs = true; + } + else + { + MainConsole.Instance.Output("You must specify in, out or all"); + return; + } if (cmdparams.Length >= 4) { @@ -172,22 +186,22 @@ namespace OpenSim.Framework.Servers if (allReqs || inReqs) { MainServer.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("In debug level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); } if (allReqs || outReqs) { WebUtil.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("Out debug level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); } } else { if (allReqs || inReqs) - MainConsole.Instance.OutputFormat("Current in debug level is {0}", MainServer.DebugLevel); + MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); if (allReqs || outReqs) - MainConsole.Instance.OutputFormat("Current out debug level is {0}", WebUtil.DebugLevel); + MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); } } -- cgit v1.1 From e29d563557bbe3a5a8f3aaf883ca92770a586e10 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 Sep 2012 00:09:17 +0100 Subject: Add request number counting to incoming HTTP requests in the same way that this was already being done for outgoing HTTP requests. This allows us to associate debug logging messages with the right request. It also allows us to put a request number on 'long request' logging even if other debug logging is not enabled, which gives us some idea of whether every request is suffering this problem or only some. This is a separate internal number not associated with any incoming number in the opensim-request-id header, this will be clarified when logging of this incoming request number is re-enabled. This commit also adds port number to HTTP IN logging to allow us to distinguish between different request numbers on different ports. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 59 +++++++++++++++------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 4e04dd8..05c2d53 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -62,6 +62,15 @@ namespace OpenSim.Framework.Servers.HttpServer /// public int DebugLevel { get; set; } + /// + /// Request number for diagnostic purposes. + /// + /// + /// This is an internal number. In some debug situations an external number may also be supplied in the + /// opensim-request-id header but we are not currently logging this. + /// + public int RequestNumber { get; private set; } + private volatile int NotSocketErrors = 0; public volatile bool HTTPDRunning = false; @@ -302,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer private void OnRequest(object source, RequestEventArgs args) { + RequestNumber++; + try { IHttpClientContext context = (IHttpClientContext)source; @@ -411,7 +422,6 @@ namespace OpenSim.Framework.Servers.HttpServer string requestMethod = request.HttpMethod; string uriString = request.RawUrl; -// string reqnum = "unknown"; int requestStartTick = Environment.TickCount; // Will be adjusted later on. @@ -535,8 +545,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", + RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); buffer = HandleHTTPRequest(request, response); break; @@ -547,8 +557,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel >= 3) m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", + RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); buffer = HandleLLSDRequests(request, response); break; @@ -641,7 +651,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (tickdiff > 3000) { m_log.InfoFormat( - "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", + "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", + RequestNumber, requestMethod, uriString, requestHandler != null ? requestHandler.Name : "", @@ -652,12 +663,9 @@ namespace OpenSim.Framework.Servers.HttpServer else if (DebugLevel >= 4) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} {1} {2} {3} from {4} took {5}ms", - requestMethod, - uriString, - requestHandler != null ? requestHandler.Name : "", - requestHandler != null ? requestHandler.Description : "", - request.RemoteIPEndPoint, + "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms", + RequestNumber, + Port, tickdiff); } } @@ -666,8 +674,14 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3} from {4}", - request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description, request.RemoteIPEndPoint); + "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}", + RequestNumber, + Port, + request.HttpMethod, + request.Url.PathAndQuery, + requestHandler.Name, + requestHandler.Description, + request.RemoteIPEndPoint); if (DebugLevel >= 5) LogIncomingInDetail(request); @@ -676,8 +690,13 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToContentTypeHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", - request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", + RequestNumber, + Port, + request.ContentType, + request.HttpMethod, + request.Url.PathAndQuery, + request.RemoteIPEndPoint); if (DebugLevel >= 5) LogIncomingInDetail(request); @@ -686,8 +705,12 @@ namespace OpenSim.Framework.Servers.HttpServer private void LogIncomingToXmlRpcHandler(OSHttpRequest request) { m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1} from {2}", - request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}", + RequestNumber, + Port, + request.HttpMethod, + request.Url.PathAndQuery, + request.RemoteIPEndPoint); if (DebugLevel >= 5) LogIncomingInDetail(request); -- cgit v1.1 From 1b0abf8f0cd417e2a37cffc96379274ad98183f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 Sep 2012 00:29:13 +0100 Subject: Comment out the long unused afaik HTTP agent handlers. As far as I know, this was only used by the IBM Rest modules, much of which has been commented out for a very long time now. Other similar code uses HTTP or stream handlers instead. So commenting this out to reduce code complexity and the need to make this facility consistent with the others where it may not be used anyway. If this facility is actually being used then please notify me or uncomment it if you are core. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 146 ++++++++++----------- .../Servers/HttpServer/Interfaces/IHttpServer.cs | 22 ++-- OpenSim/Framework/Servers/MainServer.cs | 6 +- 3 files changed, 87 insertions(+), 87 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 05c2d53..8c29ad4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -82,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected Dictionary m_llsdHandlers = new Dictionary(); protected Dictionary m_streamHandlers = new Dictionary(); protected Dictionary m_HTTPHandlers = new Dictionary(); - protected Dictionary m_agentHandlers = new Dictionary(); +// protected Dictionary m_agentHandlers = new Dictionary(); protected Dictionary m_pollHandlers = new Dictionary(); @@ -260,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer return new List(m_pollHandlers.Keys); } - // Note that the agent string is provided simply to differentiate - // the handlers - it is NOT required to be an actual agent header - // value. - public bool AddAgentHandler(string agent, IHttpAgentHandler handler) - { - lock (m_agentHandlers) - { - if (!m_agentHandlers.ContainsKey(agent)) - { - m_agentHandlers.Add(agent, handler); - return true; - } - } - - //must already have a handler for that path so return false - return false; - } - - public List GetAgentHandlerKeys() - { - lock (m_agentHandlers) - return new List(m_agentHandlers.Keys); - } +// // Note that the agent string is provided simply to differentiate +// // the handlers - it is NOT required to be an actual agent header +// // value. +// public bool AddAgentHandler(string agent, IHttpAgentHandler handler) +// { +// lock (m_agentHandlers) +// { +// if (!m_agentHandlers.ContainsKey(agent)) +// { +// m_agentHandlers.Add(agent, handler); +// return true; +// } +// } +// +// //must already have a handler for that path so return false +// return false; +// } +// +// public List GetAgentHandlerKeys() +// { +// lock (m_agentHandlers) +// return new List(m_agentHandlers.Keys); +// } public bool AddLLSDHandler(string path, LLSDMethod handler) { @@ -438,22 +438,22 @@ namespace OpenSim.Framework.Servers.HttpServer Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); - // This is the REST agent interface. We require an agent to properly identify - // itself. If the REST handler recognizes the prefix it will attempt to - // satisfy the request. If it is not recognizable, and no damage has occurred - // the request can be passed through to the other handlers. This is a low - // probability event; if a request is matched it is normally expected to be - // handled - IHttpAgentHandler agentHandler; - - if (TryGetAgentHandler(request, response, out agentHandler)) - { - if (HandleAgentRequest(agentHandler, request, response)) - { - requestEndTick = Environment.TickCount; - return; - } - } +// // This is the REST agent interface. We require an agent to properly identify +// // itself. If the REST handler recognizes the prefix it will attempt to +// // satisfy the request. If it is not recognizable, and no damage has occurred +// // the request can be passed through to the other handlers. This is a low +// // probability event; if a request is matched it is normally expected to be +// // handled +// IHttpAgentHandler agentHandler; +// +// if (TryGetAgentHandler(request, response, out agentHandler)) +// { +// if (HandleAgentRequest(agentHandler, request, response)) +// { +// requestEndTick = Environment.TickCount; +// return; +// } +// } //response.KeepAlive = true; response.SendChunked = false; @@ -830,24 +830,24 @@ namespace OpenSim.Framework.Servers.HttpServer } } - private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) - { - agentHandler = null; - - lock (m_agentHandlers) - { - foreach (IHttpAgentHandler handler in m_agentHandlers.Values) - { - if (handler.Match(request, response)) - { - agentHandler = handler; - return true; - } - } - } - - return false; - } +// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) +// { +// agentHandler = null; +// +// lock (m_agentHandlers) +// { +// foreach (IHttpAgentHandler handler in m_agentHandlers.Values) +// { +// if (handler.Match(request, response)) +// { +// agentHandler = handler; +// return true; +// } +// } +// } +// +// return false; +// } /// /// Try all the registered xmlrpc handlers when an xmlrpc request is received. @@ -1772,21 +1772,21 @@ namespace OpenSim.Framework.Servers.HttpServer m_pollHandlers.Remove(path); } - public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) - { - lock (m_agentHandlers) - { - IHttpAgentHandler foundHandler; - - if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) - { - m_agentHandlers.Remove(agent); - return true; - } - } - - return false; - } +// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) +// { +// lock (m_agentHandlers) +// { +// IHttpAgentHandler foundHandler; +// +// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) +// { +// m_agentHandlers.Remove(agent); +// return true; +// } +// } +// +// return false; +// } public void RemoveXmlRPCHandler(string method) { diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index db58f6f..0bd3aae 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer uint Port { get; } bool UseSSL { get; } - // Note that the agent string is provided simply to differentiate - // the handlers - it is NOT required to be an actual agent header - // value. - bool AddAgentHandler(string agent, IHttpAgentHandler handler); +// // Note that the agent string is provided simply to differentiate +// // the handlers - it is NOT required to be an actual agent header +// // value. +// bool AddAgentHandler(string agent, IHttpAgentHandler handler); /// /// Add a handler for an HTTP request. @@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); - /// - /// Remove the agent if it is registered. - /// - /// - /// - /// - bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); +// /// +// /// Remove the agent if it is registered. +// /// +// /// +// /// +// /// +// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); /// /// Remove an HTTP handler diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 72f9cce..4b61b18 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -231,9 +231,9 @@ namespace OpenSim.Framework.Servers foreach (String s in httpServer.GetHTTPHandlerKeys()) handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); - handlers.AppendFormat("* Agent:\n"); - foreach (String s in httpServer.GetAgentHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); +// handlers.AppendFormat("* Agent:\n"); +// foreach (String s in httpServer.GetAgentHandlerKeys()) +// handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("* LLSD:\n"); foreach (String s in httpServer.GetLLSDHandlerKeys()) -- cgit v1.1 From 772aedc7318209f9c0a2e69ed03b2d8aac4f39ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 22 Sep 2012 14:01:07 -0700 Subject: Make BaseHttpServer throws say something useful. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 8c29ad4..d139235 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -636,11 +636,11 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (IOException e) { - m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); + m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); } catch (Exception e) { - m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); + m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); SendHTML500(response); } finally -- cgit v1.1 From f4579527551f474f68f368ffdd0cd0a89d31d504 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Sep 2012 02:38:21 +0100 Subject: Fix bug where debug http level 6 could not be specified. Also converts newlines at this level to '\n' to enable them to be logged. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 +++--- OpenSim/Framework/Servers/MainServer.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d139235..ff57422 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -727,14 +727,14 @@ namespace OpenSim.Framework.Servers.HttpServer const int sampleLength = 80; char[] sampleChars = new char[sampleLength]; reader.Read(sampleChars, 0, sampleLength); - output = string.Format("[BASE HTTP SERVER]: {0}...", new string(sampleChars).Replace("\n", @"\n")); + output = new string(sampleChars); } else { - output = string.Format("[BASE HTTP SERVER]: {0}", reader.ReadToEnd()); + output = reader.ReadToEnd(); } - m_log.Debug(output); + m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); } } diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 4b61b18..ae7d515 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -177,9 +177,9 @@ namespace OpenSim.Framework.Servers return; } - if (newDebug < 0 || newDebug > 5) + if (newDebug < 0 || newDebug > 6) { - MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug); + MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); return; } -- cgit v1.1 From 531edd51d82ecd6a842a2611c99e9919634491ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:22:55 -0700 Subject: Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow. Thanks R.Gunther (rigun@rigutech.nl) https://lists.berlios.de/pipermail/opensim-users/2012-September/010986.html --- OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs | 1 + OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs | 1 + OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | 2 ++ 3 files changed, 4 insertions(+) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs index 48ced19..61161e3 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs @@ -50,6 +50,7 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + request.Proxy = null; request.ContentType = "text/xml"; MemoryStream buffer = new MemoryStream(); diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs index 451745c..727f027 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs @@ -57,6 +57,7 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 10000; diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 19c03a8..1612d4a 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs @@ -74,6 +74,7 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 20000; @@ -139,6 +140,7 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 10000; -- cgit v1.1 From 91a5c602e313b96ffaf1d50b7f0d2923a2e141ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:48:03 -0700 Subject: Revert "Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow." But the patch is here, in case anyone wants to try it. This reverts commit 531edd51d82ecd6a842a2611c99e9919634491ef. --- OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs | 1 - OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs | 1 - OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | 2 -- 3 files changed, 4 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs index 61161e3..48ced19 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs @@ -50,7 +50,6 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; - request.Proxy = null; request.ContentType = "text/xml"; MemoryStream buffer = new MemoryStream(); diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs index 727f027..451745c 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs @@ -57,7 +57,6 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; - request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 10000; diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 1612d4a..19c03a8 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs @@ -74,7 +74,6 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; - request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 20000; @@ -140,7 +139,6 @@ namespace OpenSim.Framework.Servers.HttpServer WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; - request.Proxy = null; request.ContentType = "text/xml"; request.Timeout = 10000; -- cgit v1.1 From 060d6fe8f4eba0c1b1c0cb4f52acd2fd59725c66 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 00:11:23 +0200 Subject: Allow setting max connections for an endpoint --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ff57422..d5bc3c3 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -648,7 +648,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Every month or so this will wrap and give bad numbers, not really a problem // since its just for reporting int tickdiff = requestEndTick - requestStartTick; - if (tickdiff > 3000) + if (tickdiff > 3000 && requestHandler.Name != "GetTexture") { m_log.InfoFormat( "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", -- cgit v1.1 From 1f2472d0fcd86a7ae09c01ecb3508eab001ce033 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Oct 2012 23:28:53 +0100 Subject: Extend "show stats" command to "show stats [list|all|]" This allows different categories of stats to be shown, with options to list categories or show all stats. Currently categories are scene and simulator and only a very few stats are currently registered via this mechanism. This commit also adds percentage stats for packets and blocks reused from the packet pool. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 32 ++++---------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 7a5c16d..aac9c45 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -96,11 +96,6 @@ namespace OpenSim.Framework.Servers get { return m_httpServer; } } - /// - /// Holds the non-viewer statistics collection object for this service/server - /// - protected IStatsCollector m_stats; - public BaseOpenSimServer() { m_startuptime = DateTime.Now; @@ -177,10 +172,6 @@ namespace OpenSim.Framework.Servers "show info", "Show general information about the server", HandleShow); - m_console.Commands.AddCommand("General", false, "show stats", - "show stats", - "Show statistics", HandleShow); - m_console.Commands.AddCommand("General", false, "show threads", "show threads", "Show thread status", HandleShow); @@ -226,12 +217,7 @@ namespace OpenSim.Framework.Servers { StringBuilder sb = new StringBuilder("DIAGNOSTICS\n\n"); sb.Append(GetUptimeReport()); - - if (m_stats != null) - { - sb.Append(m_stats.Report()); - } - + sb.Append(StatsManager.SimExtraStats.Report()); sb.Append(Environment.NewLine); sb.Append(GetThreadsReport()); @@ -382,10 +368,6 @@ namespace OpenSim.Framework.Servers { Notice("set log level [level] - change the console logging level only. For example, off or debug."); Notice("show info - show server information (e.g. startup path)."); - - if (m_stats != null) - Notice("show stats - show statistical information for this server"); - Notice("show threads - list tracked threads"); Notice("show uptime - show server startup time and uptime."); Notice("show version - show server version."); @@ -409,11 +391,6 @@ namespace OpenSim.Framework.Servers ShowInfo(); break; - case "stats": - if (m_stats != null) - Notice(m_stats.Report()); - break; - case "threads": Notice(GetThreadsReport()); break; @@ -604,8 +581,7 @@ namespace OpenSim.Framework.Servers public string osSecret { // Secret uuid for the simulator - get { return m_osSecret; } - + get { return m_osSecret; } } public string StatReport(IOSHttpRequest httpRequest) @@ -613,11 +589,11 @@ namespace OpenSim.Framework.Servers // If we catch a request for "callback", wrap the response in the value for jsonp if (httpRequest.Query.ContainsKey("callback")) { - return httpRequest.Query["callback"].ToString() + "(" + m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");"; + return httpRequest.Query["callback"].ToString() + "(" + StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");"; } else { - return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); + return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); } } -- cgit v1.1 From 991151250d070cb3e16d609b0f13e9de751687f1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Oct 2012 00:39:43 +0100 Subject: If we're avoiding printing a long request warning for a GetTexture CAP call, check we received a request handler first since this is not guaranteed. Resolves harmless logged exception when content type and generic xml rpc requests take more than 3 seconds. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d5bc3c3..b018e57 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -648,7 +648,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Every month or so this will wrap and give bad numbers, not really a problem // since its just for reporting int tickdiff = requestEndTick - requestStartTick; - if (tickdiff > 3000 && requestHandler.Name != "GetTexture") + if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") { m_log.InfoFormat( "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", -- cgit v1.1 From 542d0753769f939d914b5bd0a8fc5c2e03f9f2f8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 00:39:59 +0100 Subject: minor: Use LogIncomingToContentTypeHandler() method for incoming HTTP data where this wasn't already used. This allows log level 5 (log sample or large part of incoming post data) to operate and removes copy/paste. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b018e57..5d731f4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -542,11 +542,8 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleHTTPRequest(request, response); break; @@ -554,11 +551,8 @@ namespace OpenSim.Framework.Servers.HttpServer case "application/llsd+xml": case "application/xml+llsd": case "application/llsd+json": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleLLSDRequests(request, response); break; -- cgit v1.1 From 2206132ab992469f200048aa25a724d48290b9f3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 00:44:47 +0100 Subject: minor: Get content type handler logger to log "unset" for the content type instead of blank if no content type was set. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 5d731f4..410a76a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -687,7 +687,7 @@ namespace OpenSim.Framework.Servers.HttpServer "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", RequestNumber, Port, - request.ContentType, + (request.ContentType == null || request.ContentType == "") ? "not set" : request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); -- cgit v1.1 From c97890ca69df91e6590ac7dd234a3e86cf7fbaf1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 29 Oct 2012 22:53:06 +0000 Subject: Add "force gc" region console command which manually invokes garbage collection. For debugging purposes. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index aac9c45..5b2d7dc 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -192,8 +192,19 @@ namespace OpenSim.Framework.Servers "threads show", "Show thread status. Synonym for \"show threads\"", (string module, string[] args) => Notice(GetThreadsReport())); + + m_console.Commands.AddCommand("General", false, "force gc", + "force gc", + "Manually invoke runtime garbage collection. For debugging purposes", + HandleForceGc); } } + + private void HandleForceGc(string module, string[] args) + { + MainConsole.Instance.Output("Manually invoking runtime garbage collection"); + GC.Collect(); + } /// /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing -- cgit v1.1