From 9825861f4ac8d78665c33e2630824d97b356e642 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 14 Jun 2012 23:46:09 +0100
Subject: Shuffle "debug http" levels so that 1 and 2 now cause different
levels of warn to be logged if we receive invalid xml for xmlrpc.
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 35 +++++++++++++++++-----
OpenSim/Region/Application/OpenSim.cs | 9 +++---
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 9064464..35a0be4 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -82,6 +82,11 @@ namespace OpenSim.Framework.Servers.HttpServer
///
/// 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.
+ ///
public int DebugLevel { get; set; }
public uint SSLPort
@@ -450,7 +455,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (TryGetStreamHandler(handlerKey, out requestHandler))
{
- if (DebugLevel >= 1)
+ 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);
@@ -531,7 +536,7 @@ namespace OpenSim.Framework.Servers.HttpServer
case null:
case "text/html":
- if (DebugLevel >= 1)
+ 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);
@@ -543,7 +548,7 @@ namespace OpenSim.Framework.Servers.HttpServer
case "application/xml+llsd":
case "application/llsd+json":
- if (DebugLevel >= 1)
+ 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);
@@ -564,7 +569,7 @@ namespace OpenSim.Framework.Servers.HttpServer
//m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler");
if (DoWeHaveALLSDHandler(request.RawUrl))
{
- if (DebugLevel >= 1)
+ 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);
@@ -574,7 +579,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
else if (DoWeHaveAHTTPHandler(request.RawUrl))
{
- if (DebugLevel >= 1)
+ 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);
@@ -583,8 +588,7 @@ namespace OpenSim.Framework.Servers.HttpServer
}
else
{
-
- if (DebugLevel >= 1)
+ if (DebugLevel >= 3)
m_log.DebugFormat(
"[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
request.HttpMethod, request.Url.PathAndQuery);
@@ -793,8 +797,23 @@ namespace OpenSim.Framework.Servers.HttpServer
{
xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
}
- catch (XmlException)
+ catch (XmlException e)
{
+ if (DebugLevel >= 1)
+ {
+ if (DebugLevel >= 2)
+ m_log.Warn(
+ string.Format(
+ "[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}. XML was '{1}'. Sending blank response. Exception ",
+ request.RemoteIPEndPoint, requestBody),
+ e);
+ else
+ {
+ m_log.WarnFormat(
+ "[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}, length {1}. Sending blank response.",
+ request.RemoteIPEndPoint, requestBody.Length);
+ }
+ }
}
if (xmlRprcRequest != null)
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 57a3c69..96d41a4 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -250,10 +250,11 @@ namespace OpenSim
m_console.Commands.AddCommand("Comms", false, "debug http",
"debug http ",
- "Turn on inbound http request debugging for everything except the event queue (see debug eq).",
- "If level >= 2 then the handler used to service the request is logged.\n"
- + "If level >= 1 then incoming HTTP requests are logged.\n"
- + "If level <= 0 then no extra http logging is done.\n",
+ "Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
+ "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",
Debug);
m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
--
cgit v1.1
From 93ba0332c4ccbb0c60e6d60fff71dc7d1567c9dd Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 14 Jun 2012 23:54:12 +0100
Subject: minor: Extend 'debug http' usage statement to 0..3 from 0..2
---
OpenSim/Region/Application/OpenSim.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 96d41a4..00ae880 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -927,7 +927,7 @@ namespace OpenSim
}
}
- MainConsole.Instance.Output("Usage: debug http 0..2");
+ MainConsole.Instance.Output("Usage: debug http 0..3");
break;
case "scene":
--
cgit v1.1
From 6993a26ba599ae38dc6f66332980657d5621987a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 00:40:12 +0100
Subject: Get rid of some unnecessary null checks in
RegionApplicationBase.StartupSpecific() - a constructor can never return
null.
Also adds some method doc to MainServer
---
OpenSim/Framework/Servers/MainServer.cs | 31 +++++++++++++++++++---
.../Region/ClientStack/RegionApplicationBase.cs | 14 ++++------
2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index b8ab8d9..ea972ef 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -47,20 +47,43 @@ namespace OpenSim.Framework.Servers
set { instance = value; }
}
- public static IHttpServer GetHttpServer(uint port)
+ ///
+ /// Add an already started HTTP server to the collection of known servers.
+ ///
+ ///
+ public static void AddHttpServer(BaseHttpServer server)
{
- return GetHttpServer(port,null);
+ m_Servers.Add(server.Port, server);
}
- public static void AddHttpServer(BaseHttpServer server)
+ ///
+ /// Get the default http server or an http server for a specific port.
+ ///
+ ///
+ /// If the requested HTTP server doesn't already exist then a new one is instantiated and started.
+ ///
+ ///
+ /// If 0 then the default HTTP server is returned.
+ public static IHttpServer GetHttpServer(uint port)
{
- m_Servers.Add(server.Port, server);
+ return GetHttpServer(port, null);
}
+ ///
+ /// Get the default http server, an http server for a specific port
+ /// and/or an http server bound to a specific address
+ ///
+ ///
+ /// If the requested HTTP server doesn't already exist then a new one is instantiated and started.
+ ///
+ ///
+ /// If 0 then the default HTTP server is returned.
+ /// A specific IP address to bind to. If null then the default IP address is used.
public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr)
{
if (port == 0)
return Instance;
+
if (instance != null && port == Instance.Port)
return Instance;
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 6e78d6d..27a5879 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -99,17 +99,13 @@ namespace OpenSim.Region.ClientStack
// "OOB" Server
if (m_networkServersInfo.ssl_listener)
{
- BaseHttpServer server = null;
- server = new BaseHttpServer(
+ BaseHttpServer server = new BaseHttpServer(
m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path,
m_networkServersInfo.cert_pass);
- // Add the server to m_Servers
- if(server != null)
- {
- m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port);
- MainServer.AddHttpServer(server);
- server.Start();
- }
+
+ m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port);
+ MainServer.AddHttpServer(server);
+ server.Start();
}
base.StartupSpecific();
--
cgit v1.1
From 10e87f9cdc6c2cbd01da863e01abca8f7e671f9c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 00:59:53 +0100
Subject: Make XMLRPCModule use an existing HTTP server if one already exists
on the desired port.
---
OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
index 40ffcb4..0003af2 100644
--- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -131,11 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
{
// Start http server
// Attach xmlrpc handlers
- m_log.Info("[XML RPC MODULE]: " +
- "Starting up XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
- BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
+// m_log.InfoFormat(
+// "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.",
+// m_remoteDataPort);
+
+ IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort);
httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
- httpServer.Start();
}
}
--
cgit v1.1
From 478acfff34b94c7c42bdb927be531b669c43af72 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 01:24:36 +0100
Subject: When setting debug http level, do this for all known http servers,
not just the main instance.
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 20 +++++------
OpenSim/Framework/Servers/MainServer.cs | 41 ++++++++++++++++------
OpenSim/Region/Application/OpenSim.cs | 2 +-
3 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 35a0be4..6b52485 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -53,6 +53,16 @@ namespace OpenSim.Framework.Servers.HttpServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
+ ///
+ /// 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.
+ ///
+ public int DebugLevel { get; set; }
+
private volatile int NotSocketErrors = 0;
public volatile bool HTTPDRunning = false;
@@ -79,16 +89,6 @@ namespace OpenSim.Framework.Servers.HttpServer
private PollServiceRequestManager m_PollServiceManager;
- ///
- /// 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.
- ///
- public int DebugLevel { get; set; }
-
public uint SSLPort
{
get { return m_sslport; }
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index ea972ef..efac6e1 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -38,8 +38,23 @@ namespace OpenSim.Framework.Servers
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static BaseHttpServer instance = null;
- private static Dictionary m_Servers =
- new Dictionary();
+ private static Dictionary m_Servers = new Dictionary();
+
+ public static int DebugLevel
+ {
+ get { return s_debugLevel; }
+ set
+ {
+ s_debugLevel = value;
+ Instance.DebugLevel = s_debugLevel;
+
+ lock (m_Servers)
+ foreach (BaseHttpServer server in m_Servers.Values)
+ server.DebugLevel = s_debugLevel;
+ }
+ }
+
+ private static int s_debugLevel;
public static BaseHttpServer Instance
{
@@ -53,7 +68,8 @@ namespace OpenSim.Framework.Servers
///
public static void AddHttpServer(BaseHttpServer server)
{
- m_Servers.Add(server.Port, server);
+ lock (m_Servers)
+ m_Servers.Add(server.Port, server);
}
///
@@ -87,18 +103,21 @@ namespace OpenSim.Framework.Servers
if (instance != null && port == Instance.Port)
return Instance;
- if (m_Servers.ContainsKey(port))
- return m_Servers[port];
+ lock (m_Servers)
+ {
+ if (m_Servers.ContainsKey(port))
+ return m_Servers[port];
- m_Servers[port] = new BaseHttpServer(port);
+ m_Servers[port] = new BaseHttpServer(port);
- if (ipaddr != null)
- m_Servers[port].ListenIPAddress = ipaddr;
+ if (ipaddr != null)
+ m_Servers[port].ListenIPAddress = ipaddr;
- m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
- m_Servers[port].Start();
+ m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
+ m_Servers[port].Start();
+ }
return m_Servers[port];
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 00ae880..9043137 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -921,7 +921,7 @@ namespace OpenSim
int newDebug;
if (int.TryParse(args[2], out newDebug))
{
- MainServer.Instance.DebugLevel = newDebug;
+ MainServer.DebugLevel = newDebug;
MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
break;
}
--
cgit v1.1
From aeed4d3041af75cf18d140208cc4c744a73d0492 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 01:27:29 +0100
Subject: minor: Tell user the current debug http level if "debug http" console
command is executed without a level parameter
---
OpenSim/Region/Application/OpenSim.cs | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 9043137..abb30a9 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -249,12 +249,13 @@ namespace OpenSim
Debug);
m_console.Commands.AddCommand("Comms", false, "debug http",
- "debug http ",
+ "debug http []",
"Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
"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 >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
+ + "If no level is specified then the current level is returned.",
Debug);
m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
@@ -926,8 +927,15 @@ namespace OpenSim
break;
}
}
+ else if (args.Length == 2)
+ {
+ MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
+ }
+ else
+ {
+ MainConsole.Instance.Output("Usage: debug http 0..3");
+ }
- MainConsole.Instance.Output("Usage: debug http 0..3");
break;
case "scene":
--
cgit v1.1
From 257b1b517dec58bf902bac63bc7ab7080286d415 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 02:03:50 +0100
Subject: Add main instance to internal MainServer.m_Servers list to simplify
internal logic.
This does require the server to be added before it is set as the main Instance
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 8 ---
OpenSim/Framework/Servers/MainServer.cs | 64 +++++++++++++++++++++-
.../Caps/EventQueue/Tests/EventQueueTests.cs | 11 +++-
.../Region/ClientStack/RegionApplicationBase.cs | 1 +
OpenSim/Server/Base/HttpServerBase.cs | 13 +----
5 files changed, 75 insertions(+), 22 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 6b52485..0db1329 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -53,14 +53,6 @@ namespace OpenSim.Framework.Servers.HttpServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
- ///
- /// 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.
- ///
public int DebugLevel { get; set; }
private volatile int NotSocketErrors = 0;
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index efac6e1..becbbc2 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
using System.Reflection;
using System.Net;
@@ -40,13 +41,20 @@ namespace OpenSim.Framework.Servers
private static BaseHttpServer instance = null;
private static Dictionary m_Servers = new Dictionary();
+ ///
+ /// 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.
+ ///
public static int DebugLevel
{
get { return s_debugLevel; }
set
{
s_debugLevel = value;
- Instance.DebugLevel = s_debugLevel;
lock (m_Servers)
foreach (BaseHttpServer server in m_Servers.Values)
@@ -56,20 +64,70 @@ namespace OpenSim.Framework.Servers
private static int s_debugLevel;
+ ///
+ /// Set the main HTTP server instance.
+ ///
+ ///
+ /// This will be used to register all handlers that listen to the default port.
+ ///
+ ///
+ /// Thrown if the HTTP server has not already been registered via AddHttpServer()
+ ///
public static BaseHttpServer Instance
{
get { return instance; }
- set { instance = value; }
+
+ set
+ {
+ lock (m_Servers)
+ if (!m_Servers.ContainsValue(value))
+ throw new Exception("HTTP server must already have been registered to be set as the main instance");
+
+ instance = value;
+ }
}
///
- /// Add an already started HTTP server to the collection of known servers.
+ /// Register an already started HTTP server to the collection of known servers.
///
///
public static void AddHttpServer(BaseHttpServer server)
{
lock (m_Servers)
+ {
+ if (m_Servers.ContainsKey(server.Port))
+ throw new Exception(string.Format("HTTP server for port {0} already exists.", server.Port));
+
m_Servers.Add(server.Port, server);
+ }
+ }
+
+ ///
+ /// Removes the http server listening on the given port.
+ ///
+ ///
+ /// It is the responsibility of the caller to do clean up.
+ ///
+ ///
+ ///
+ public static bool RemoveHttpServer(uint port)
+ {
+ lock (m_Servers)
+ return m_Servers.Remove(port);
+ }
+
+ ///
+ /// Does this collection of servers contain one with the given port?
+ ///
+ ///
+ /// Unlike GetHttpServer, this will not instantiate a server if one does not exist on that port.
+ ///
+ ///
+ /// true if a server with the given port is registered, false otherwise.
+ public static bool ContainsHttpServer(uint port)
+ {
+ lock (m_Servers)
+ return m_Servers.ContainsKey(port);
}
///
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
index c25b58c..cd70410 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
@@ -51,7 +51,16 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
[SetUp]
public void SetUp()
{
- MainServer.Instance = new BaseHttpServer(9999, false, 9998, "");
+ uint port = 9999;
+ uint sslPort = 9998;
+
+ // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
+ // variables and the VM is not restarted between tests.
+ MainServer.RemoveHttpServer(port);
+
+ BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "");
+ MainServer.AddHttpServer(server);
+ MainServer.Instance = server;
IConfigSource config = new IniConfigSource();
config.AddConfig("Startup");
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 27a5879..c4324e8 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -94,6 +94,7 @@ namespace OpenSim.Region.ClientStack
m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
m_httpServer.Start();
+ MainServer.AddHttpServer(m_httpServer);
MainServer.Instance = m_httpServer;
// "OOB" Server
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index d471559..7014303 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -138,6 +138,7 @@ namespace OpenSim.Server.Base
m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
}
+ MainServer.AddHttpServer(m_HttpServer);
MainServer.Instance = m_HttpServer;
// If https_listener = true, then add an ssl listener on the https_port...
@@ -157,16 +158,8 @@ namespace OpenSim.Server.Base
System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
Thread.CurrentThread.Abort();
}
- // Add our https_server
- BaseHttpServer server = null;
- server = new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass);
- if (server != null)
- {
- m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", https_port);
- m_Servers.Add(https_port,server);
- }
- else
- System.Console.WriteLine(String.Format("Failed to start HTTPS server on port {0}",https_port));
+
+ m_Servers.Add(https_port, new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
}
}
--
cgit v1.1
From 94517c8d5c63f9e8a1ea9a83b04db956f27aa25d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 02:51:52 +0100
Subject: Make the "debug http" command available for robust as well as the
simulator. This allows one to see incoming requests as they happen.
This required making everything use the common MainServer class for registering and retrieving http servers, rather than duplicate structures.
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 3 +
OpenSim/Framework/Servers/MainServer.cs | 60 +++++++++++++++--
OpenSim/Region/Application/OpenSim.cs | 34 +---------
OpenSim/Server/Base/HttpServerBase.cs | 78 +++++-----------------
OpenSim/Server/ServerMain.cs | 26 ++++----
prebuild.xml | 1 +
6 files changed, 92 insertions(+), 110 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 0db1329..3de7f9c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1557,6 +1557,9 @@ namespace OpenSim.Framework.Servers.HttpServer
private void StartHTTP()
{
+ m_log.InfoFormat(
+ "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port);
+
try
{
//m_httpListener = new HttpListener();
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index becbbc2..07ff60c 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -30,13 +30,15 @@ using System.Collections.Generic;
using System.Reflection;
using System.Net;
using log4net;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Framework.Servers.HttpServer;
namespace OpenSim.Framework.Servers
{
public class MainServer
{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static BaseHttpServer instance = null;
private static Dictionary m_Servers = new Dictionary();
@@ -88,6 +90,57 @@ namespace OpenSim.Framework.Servers
}
///
+ /// Get all the registered servers.
+ ///
+ ///
+ /// Returns a copy of the dictionary so this can be iterated through without locking.
+ ///
+ ///
+ public static Dictionary Servers
+ {
+ get { return new Dictionary(m_Servers); }
+ }
+
+
+ public static void RegisterHttpConsoleCommands(ICommandConsole console)
+ {
+ console.Commands.AddCommand(
+ "Comms", 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 no level is specified then the current level is returned.",
+ HandleDebugHttpCommand);
+ }
+
+ ///
+ /// Turn on some debugging values for OpenSim.
+ ///
+ ///
+ private static void HandleDebugHttpCommand(string module, string[] args)
+ {
+ if (args.Length == 3)
+ {
+ int newDebug;
+ if (int.TryParse(args[2], out newDebug))
+ {
+ MainServer.DebugLevel = newDebug;
+ MainConsole.Instance.OutputFormat("Debug http 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..3");
+ }
+ }
+
+ ///
/// Register an already started HTTP server to the collection of known servers.
///
///
@@ -171,11 +224,10 @@ namespace OpenSim.Framework.Servers
if (ipaddr != null)
m_Servers[port].ListenIPAddress = ipaddr;
- m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
m_Servers[port].Start();
- }
- return m_Servers[port];
+ return m_Servers[port];
+ }
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index abb30a9..faa9e09 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -231,6 +231,8 @@ namespace OpenSim
///
private void RegisterConsoleCommands()
{
+ MainServer.RegisterHttpConsoleCommands(m_console);
+
m_console.Commands.AddCommand("Objects", false, "force update",
"force update",
"Force the update of all objects on clients",
@@ -248,16 +250,6 @@ namespace OpenSim
+ "If an avatar name is given then only packets from that avatar are logged",
Debug);
- m_console.Commands.AddCommand("Comms", false, "debug http",
- "debug http []",
- "Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
- "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 no level is specified then the current level is returned.",
- Debug);
-
m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
m_console.Commands.AddCommand("Regions", false, "debug scene",
@@ -916,28 +908,6 @@ namespace OpenSim
break;
- case "http":
- if (args.Length == 3)
- {
- int newDebug;
- if (int.TryParse(args[2], out newDebug))
- {
- MainServer.DebugLevel = newDebug;
- MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
- break;
- }
- }
- else if (args.Length == 2)
- {
- MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
- }
- else
- {
- MainConsole.Instance.Output("Usage: debug http 0..3");
- }
-
- break;
-
case "scene":
if (args.Length == 4)
{
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 7014303..7ba0ca8 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -42,42 +42,9 @@ namespace OpenSim.Server.Base
{
// Logger
//
- private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- // The http server instance
- //
- protected BaseHttpServer m_HttpServer = null;
- protected uint m_Port = 0;
- protected Dictionary m_Servers =
- new Dictionary();
- protected uint m_consolePort = 0;
-
- public IHttpServer HttpServer
- {
- get { return m_HttpServer; }
- }
-
- public uint DefaultPort
- {
- get { return m_Port; }
- }
-
- public IHttpServer GetHttpServer(uint port)
- {
- m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
- if (port == m_Port)
- return HttpServer;
-
- if (m_Servers.ContainsKey(port))
- return m_Servers[port];
-
- m_Servers[port] = new BaseHttpServer(port);
-
- m_Log.InfoFormat("[SERVER]: Starting new HTTP server on port {0}", port);
- m_Servers[port].Start();
-
- return m_Servers[port];
- }
+ private uint m_consolePort;
// Handle all the automagical stuff
//
@@ -94,19 +61,21 @@ namespace OpenSim.Server.Base
System.Console.WriteLine("Section 'Network' not found, server can't start");
Thread.CurrentThread.Abort();
}
+
uint port = (uint)networkConfig.GetInt("port", 0);
if (port == 0)
{
-
Thread.CurrentThread.Abort();
}
- //
+
bool ssl_main = networkConfig.GetBoolean("https_main",false);
bool ssl_listener = networkConfig.GetBoolean("https_listener",false);
m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0);
- m_Port = port;
+
+ BaseHttpServer httpServer = null;
+
//
// This is where to make the servers:
//
@@ -118,8 +87,7 @@ namespace OpenSim.Server.Base
//
if ( !ssl_main )
{
- m_HttpServer = new BaseHttpServer(port);
-
+ httpServer = new BaseHttpServer(port);
}
else
{
@@ -135,11 +103,12 @@ namespace OpenSim.Server.Base
System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
Thread.CurrentThread.Abort();
}
- m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
+
+ httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
}
- MainServer.AddHttpServer(m_HttpServer);
- MainServer.Instance = m_HttpServer;
+ MainServer.AddHttpServer(httpServer);
+ MainServer.Instance = httpServer;
// If https_listener = true, then add an ssl listener on the https_port...
if ( ssl_listener == true ) {
@@ -159,34 +128,23 @@ namespace OpenSim.Server.Base
Thread.CurrentThread.Abort();
}
- m_Servers.Add(https_port, new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
+ MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
}
}
protected override void Initialise()
{
- m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port);
- m_HttpServer.Start();
-
- if (m_Servers.Count > 0)
- {
- foreach (BaseHttpServer s in m_Servers.Values)
- {
- if (!s.UseSSL)
- m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", s.Port);
- else
- m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", s.Port);
+ foreach (BaseHttpServer s in MainServer.Servers.Values)
+ s.Start();
- s.Start();
- }
- }
+ MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
if (MainConsole.Instance is RemoteConsole)
{
if (m_consolePort == 0)
- ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer);
+ ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
else
- ((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort));
+ ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
}
}
}
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index 9503c4c..21fb678 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -30,6 +30,7 @@ using log4net;
using System.Reflection;
using System;
using System.Collections.Generic;
+using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
@@ -92,27 +93,24 @@ namespace OpenSim.Server
if (parts.Length > 1)
friendlyName = parts[1];
- IHttpServer server = m_Server.HttpServer;
- if (port != 0)
- server = m_Server.GetHttpServer(port);
+ IHttpServer server;
- if (port != m_Server.DefaultPort && port != 0)
- m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port);
+ if (port != 0)
+ server = MainServer.GetHttpServer(port);
else
- m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
+ server = MainServer.Instance;
+
+ m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port);
IServiceConnector connector = null;
- Object[] modargs = new Object[] { m_Server.Config, server,
- configName };
- connector = ServerUtils.LoadPlugin(conn,
- modargs);
+ Object[] modargs = new Object[] { m_Server.Config, server, configName };
+ connector = ServerUtils.LoadPlugin(conn, modargs);
+
if (connector == null)
{
modargs = new Object[] { m_Server.Config, server };
- connector =
- ServerUtils.LoadPlugin(conn,
- modargs);
+ connector = ServerUtils.LoadPlugin(conn, modargs);
}
if (connector != null)
@@ -132,4 +130,4 @@ namespace OpenSim.Server
return 0;
}
}
-}
+}
\ No newline at end of file
diff --git a/prebuild.xml b/prebuild.xml
index d02f2b9..45f58c7 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1385,6 +1385,7 @@
+
--
cgit v1.1