aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-06-15 02:53:34 +0100
committerMelanie2012-06-15 02:53:34 +0100
commit30d872caadc063e15a48c77e40c83dded8b4400e (patch)
tree92b0dcb17d7851f7c4b27887d5960c273bf0cef1 /OpenSim
parentMerge branch 'master' into careminster (diff)
parentMake the "debug http" command available for robust as well as the simulator. ... (diff)
downloadopensim-SC-30d872caadc063e15a48c77e40c83dded8b4400e.zip
opensim-SC-30d872caadc063e15a48c77e40c83dded8b4400e.tar.gz
opensim-SC-30d872caadc063e15a48c77e40c83dded8b4400e.tar.bz2
opensim-SC-30d872caadc063e15a48c77e40c83dded8b4400e.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs40
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs184
-rw-r--r--OpenSim/Region/Application/OpenSim.cs25
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs11
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs15
-rw-r--r--OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs9
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs87
-rw-r--r--OpenSim/Server/ServerMain.cs26
8 files changed, 249 insertions, 148 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 31af44c..1d5b426 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -53,6 +53,8 @@ namespace OpenSim.Framework.Servers.HttpServer
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 54 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
55 55
56 public int DebugLevel { get; set; }
57
56 private volatile int NotSocketErrors = 0; 58 private volatile int NotSocketErrors = 0;
57 public volatile bool HTTPDRunning = false; 59 public volatile bool HTTPDRunning = false;
58 60
@@ -79,11 +81,6 @@ namespace OpenSim.Framework.Servers.HttpServer
79 81
80 private PollServiceRequestManager m_PollServiceManager; 82 private PollServiceRequestManager m_PollServiceManager;
81 83
82 /// <summary>
83 /// Control the printing of certain debug messages.
84 /// </summary>
85 public int DebugLevel { get; set; }
86
87 public uint SSLPort 84 public uint SSLPort
88 { 85 {
89 get { return m_sslport; } 86 get { return m_sslport; }
@@ -450,7 +447,7 @@ namespace OpenSim.Framework.Servers.HttpServer
450 447
451 if (TryGetStreamHandler(handlerKey, out requestHandler)) 448 if (TryGetStreamHandler(handlerKey, out requestHandler))
452 { 449 {
453 if (DebugLevel >= 1) 450 if (DebugLevel >= 3)
454 m_log.DebugFormat( 451 m_log.DebugFormat(
455 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", 452 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}",
456 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); 453 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
@@ -531,7 +528,7 @@ namespace OpenSim.Framework.Servers.HttpServer
531 case null: 528 case null:
532 case "text/html": 529 case "text/html":
533 530
534 if (DebugLevel >= 1) 531 if (DebugLevel >= 3)
535 m_log.DebugFormat( 532 m_log.DebugFormat(
536 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 533 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
537 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 534 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@@ -543,7 +540,7 @@ namespace OpenSim.Framework.Servers.HttpServer
543 case "application/xml+llsd": 540 case "application/xml+llsd":
544 case "application/llsd+json": 541 case "application/llsd+json":
545 542
546 if (DebugLevel >= 1) 543 if (DebugLevel >= 3)
547 m_log.DebugFormat( 544 m_log.DebugFormat(
548 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 545 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
549 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 546 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@@ -564,7 +561,7 @@ namespace OpenSim.Framework.Servers.HttpServer
564 //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler"); 561 //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler");
565 if (DoWeHaveALLSDHandler(request.RawUrl)) 562 if (DoWeHaveALLSDHandler(request.RawUrl))
566 { 563 {
567 if (DebugLevel >= 1) 564 if (DebugLevel >= 3)
568 m_log.DebugFormat( 565 m_log.DebugFormat(
569 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 566 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
570 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 567 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@@ -574,7 +571,7 @@ namespace OpenSim.Framework.Servers.HttpServer
574 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); 571 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
575 else if (DoWeHaveAHTTPHandler(request.RawUrl)) 572 else if (DoWeHaveAHTTPHandler(request.RawUrl))
576 { 573 {
577 if (DebugLevel >= 1) 574 if (DebugLevel >= 3)
578 m_log.DebugFormat( 575 m_log.DebugFormat(
579 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 576 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
580 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 577 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@@ -583,8 +580,7 @@ namespace OpenSim.Framework.Servers.HttpServer
583 } 580 }
584 else 581 else
585 { 582 {
586 583 if (DebugLevel >= 3)
587 if (DebugLevel >= 1)
588 m_log.DebugFormat( 584 m_log.DebugFormat(
589 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", 585 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
590 request.HttpMethod, request.Url.PathAndQuery); 586 request.HttpMethod, request.Url.PathAndQuery);
@@ -793,8 +789,23 @@ namespace OpenSim.Framework.Servers.HttpServer
793 { 789 {
794 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); 790 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
795 } 791 }
796 catch (XmlException) 792 catch (XmlException e)
797 { 793 {
794 if (DebugLevel >= 1)
795 {
796 if (DebugLevel >= 2)
797 m_log.Warn(
798 string.Format(
799 "[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}. XML was '{1}'. Sending blank response. Exception ",
800 request.RemoteIPEndPoint, requestBody),
801 e);
802 else
803 {
804 m_log.WarnFormat(
805 "[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}, length {1}. Sending blank response.",
806 request.RemoteIPEndPoint, requestBody.Length);
807 }
808 }
798 } 809 }
799 810
800 if (xmlRprcRequest != null) 811 if (xmlRprcRequest != null)
@@ -1570,6 +1581,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1570 1581
1571 private void StartHTTP() 1582 private void StartHTTP()
1572 { 1583 {
1584 m_log.InfoFormat(
1585 "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port);
1586
1573 try 1587 try
1574 { 1588 {
1575 //m_httpListener = new HttpListener(); 1589 //m_httpListener = new HttpListener();
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index b8ab8d9..07ff60c 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -25,57 +25,209 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using System.Net; 31using System.Net;
31using log4net; 32using log4net;
33using OpenSim.Framework;
34using OpenSim.Framework.Console;
32using OpenSim.Framework.Servers.HttpServer; 35using OpenSim.Framework.Servers.HttpServer;
33 36
34namespace OpenSim.Framework.Servers 37namespace OpenSim.Framework.Servers
35{ 38{
36 public class MainServer 39 public class MainServer
37 { 40 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 42
40 private static BaseHttpServer instance = null; 43 private static BaseHttpServer instance = null;
41 private static Dictionary<uint, BaseHttpServer> m_Servers = 44 private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>();
42 new Dictionary<uint, BaseHttpServer>();
43 45
46 /// <summary>
47 /// Control the printing of certain debug messages.
48 /// </summary>
49 /// <remarks>
50 /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data.
51 /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data.
52 /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged.
53 /// </remarks>
54 public static int DebugLevel
55 {
56 get { return s_debugLevel; }
57 set
58 {
59 s_debugLevel = value;
60
61 lock (m_Servers)
62 foreach (BaseHttpServer server in m_Servers.Values)
63 server.DebugLevel = s_debugLevel;
64 }
65 }
66
67 private static int s_debugLevel;
68
69 /// <summary>
70 /// Set the main HTTP server instance.
71 /// </summary>
72 /// <remarks>
73 /// This will be used to register all handlers that listen to the default port.
74 /// </remarks>
75 /// <exception cref='Exception'>
76 /// Thrown if the HTTP server has not already been registered via AddHttpServer()
77 /// </exception>
44 public static BaseHttpServer Instance 78 public static BaseHttpServer Instance
45 { 79 {
46 get { return instance; } 80 get { return instance; }
47 set { instance = value; } 81
82 set
83 {
84 lock (m_Servers)
85 if (!m_Servers.ContainsValue(value))
86 throw new Exception("HTTP server must already have been registered to be set as the main instance");
87
88 instance = value;
89 }
48 } 90 }
49 91
50 public static IHttpServer GetHttpServer(uint port) 92 /// <summary>
93 /// Get all the registered servers.
94 /// </summary>
95 /// <remarks>
96 /// Returns a copy of the dictionary so this can be iterated through without locking.
97 /// </remarks>
98 /// <value></value>
99 public static Dictionary<uint, BaseHttpServer> Servers
100 {
101 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
102 }
103
104
105 public static void RegisterHttpConsoleCommands(ICommandConsole console)
106 {
107 console.Commands.AddCommand(
108 "Comms", false, "debug http", "debug http [<level>]",
109 "Turn on inbound non-poll http request debugging.",
110 "If level <= 0, then no extra logging is done.\n"
111 + "If level >= 1, then short warnings are logged when receiving bad input data.\n"
112 + "If level >= 2, then long warnings are logged when receiving bad input data.\n"
113 + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
114 + "If no level is specified then the current level is returned.",
115 HandleDebugHttpCommand);
116 }
117
118 /// <summary>
119 /// Turn on some debugging values for OpenSim.
120 /// </summary>
121 /// <param name="args"></param>
122 private static void HandleDebugHttpCommand(string module, string[] args)
51 { 123 {
52 return GetHttpServer(port,null); 124 if (args.Length == 3)
125 {
126 int newDebug;
127 if (int.TryParse(args[2], out newDebug))
128 {
129 MainServer.DebugLevel = newDebug;
130 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
131 }
132 }
133 else if (args.Length == 2)
134 {
135 MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
136 }
137 else
138 {
139 MainConsole.Instance.Output("Usage: debug http 0..3");
140 }
53 } 141 }
54 142
143 /// <summary>
144 /// Register an already started HTTP server to the collection of known servers.
145 /// </summary>
146 /// <param name='server'></param>
55 public static void AddHttpServer(BaseHttpServer server) 147 public static void AddHttpServer(BaseHttpServer server)
56 { 148 {
57 m_Servers.Add(server.Port, server); 149 lock (m_Servers)
150 {
151 if (m_Servers.ContainsKey(server.Port))
152 throw new Exception(string.Format("HTTP server for port {0} already exists.", server.Port));
153
154 m_Servers.Add(server.Port, server);
155 }
156 }
157
158 /// <summary>
159 /// Removes the http server listening on the given port.
160 /// </summary>
161 /// <remarks>
162 /// It is the responsibility of the caller to do clean up.
163 /// </remarks>
164 /// <param name='port'></param>
165 /// <returns></returns>
166 public static bool RemoveHttpServer(uint port)
167 {
168 lock (m_Servers)
169 return m_Servers.Remove(port);
170 }
171
172 /// <summary>
173 /// Does this collection of servers contain one with the given port?
174 /// </summary>
175 /// <remarks>
176 /// Unlike GetHttpServer, this will not instantiate a server if one does not exist on that port.
177 /// </remarks>
178 /// <param name='port'></param>
179 /// <returns>true if a server with the given port is registered, false otherwise.</returns>
180 public static bool ContainsHttpServer(uint port)
181 {
182 lock (m_Servers)
183 return m_Servers.ContainsKey(port);
58 } 184 }
59 185
186 /// <summary>
187 /// Get the default http server or an http server for a specific port.
188 /// </summary>
189 /// <remarks>
190 /// If the requested HTTP server doesn't already exist then a new one is instantiated and started.
191 /// </remarks>
192 /// <returns></returns>
193 /// <param name='port'>If 0 then the default HTTP server is returned.</param>
194 public static IHttpServer GetHttpServer(uint port)
195 {
196 return GetHttpServer(port, null);
197 }
198
199 /// <summary>
200 /// Get the default http server, an http server for a specific port
201 /// and/or an http server bound to a specific address
202 /// </summary>
203 /// <remarks>
204 /// If the requested HTTP server doesn't already exist then a new one is instantiated and started.
205 /// </remarks>
206 /// <returns></returns>
207 /// <param name='port'>If 0 then the default HTTP server is returned.</param>
208 /// <param name='ipaddr'>A specific IP address to bind to. If null then the default IP address is used.</param>
60 public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr) 209 public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr)
61 { 210 {
62 if (port == 0) 211 if (port == 0)
63 return Instance; 212 return Instance;
213
64 if (instance != null && port == Instance.Port) 214 if (instance != null && port == Instance.Port)
65 return Instance; 215 return Instance;
66 216
67 if (m_Servers.ContainsKey(port)) 217 lock (m_Servers)
68 return m_Servers[port]; 218 {
219 if (m_Servers.ContainsKey(port))
220 return m_Servers[port];
69 221
70 m_Servers[port] = new BaseHttpServer(port); 222 m_Servers[port] = new BaseHttpServer(port);
71 223
72 if (ipaddr != null) 224 if (ipaddr != null)
73 m_Servers[port].ListenIPAddress = ipaddr; 225 m_Servers[port].ListenIPAddress = ipaddr;
74 226
75 m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port); 227 m_Servers[port].Start();
76 m_Servers[port].Start();
77 228
78 return m_Servers[port]; 229 return m_Servers[port];
230 }
79 } 231 }
80 } 232 }
81} 233} \ No newline at end of file
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index f4812e6..f418d7b 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -231,6 +231,8 @@ namespace OpenSim
231 /// </summary> 231 /// </summary>
232 private void RegisterConsoleCommands() 232 private void RegisterConsoleCommands()
233 { 233 {
234 MainServer.RegisterHttpConsoleCommands(m_console);
235
234 m_console.Commands.AddCommand("Objects", false, "force update", 236 m_console.Commands.AddCommand("Objects", false, "force update",
235 "force update", 237 "force update",
236 "Force the update of all objects on clients", 238 "Force the update of all objects on clients",
@@ -248,14 +250,6 @@ namespace OpenSim
248 + "If an avatar name is given then only packets from that avatar are logged", 250 + "If an avatar name is given then only packets from that avatar are logged",
249 Debug); 251 Debug);
250 252
251 m_console.Commands.AddCommand("Comms", false, "debug http",
252 "debug http <level>",
253 "Turn on inbound http request debugging for everything except the event queue (see debug eq).",
254 "If level >= 2 then the handler used to service the request is logged.\n"
255 + "If level >= 1 then incoming HTTP requests are logged.\n"
256 + "If level <= 0 then no extra http logging is done.\n",
257 Debug);
258
259 m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); 253 m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
260 254
261 m_console.Commands.AddCommand("Regions", false, "debug scene", 255 m_console.Commands.AddCommand("Regions", false, "debug scene",
@@ -914,21 +908,6 @@ namespace OpenSim
914 908
915 break; 909 break;
916 910
917 case "http":
918 if (args.Length == 3)
919 {
920 int newDebug;
921 if (int.TryParse(args[2], out newDebug))
922 {
923 MainServer.Instance.DebugLevel = newDebug;
924 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug);
925 break;
926 }
927 }
928
929 MainConsole.Instance.Output("Usage: debug http 0..2");
930 break;
931
932 case "scene": 911 case "scene":
933 if (args.Length == 4) 912 if (args.Length == 4)
934 { 913 {
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
51 [SetUp] 51 [SetUp]
52 public void SetUp() 52 public void SetUp()
53 { 53 {
54 MainServer.Instance = new BaseHttpServer(9999, false, 9998, ""); 54 uint port = 9999;
55 uint sslPort = 9998;
56
57 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
58 // variables and the VM is not restarted between tests.
59 MainServer.RemoveHttpServer(port);
60
61 BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "");
62 MainServer.AddHttpServer(server);
63 MainServer.Instance = server;
55 64
56 IConfigSource config = new IniConfigSource(); 65 IConfigSource config = new IniConfigSource();
57 config.AddConfig("Startup"); 66 config.AddConfig("Startup");
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 6e78d6d..c4324e8 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -94,22 +94,19 @@ namespace OpenSim.Region.ClientStack
94 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort); 94 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
95 m_httpServer.Start(); 95 m_httpServer.Start();
96 96
97 MainServer.AddHttpServer(m_httpServer);
97 MainServer.Instance = m_httpServer; 98 MainServer.Instance = m_httpServer;
98 99
99 // "OOB" Server 100 // "OOB" Server
100 if (m_networkServersInfo.ssl_listener) 101 if (m_networkServersInfo.ssl_listener)
101 { 102 {
102 BaseHttpServer server = null; 103 BaseHttpServer server = new BaseHttpServer(
103 server = new BaseHttpServer(
104 m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, 104 m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path,
105 m_networkServersInfo.cert_pass); 105 m_networkServersInfo.cert_pass);
106 // Add the server to m_Servers 106
107 if(server != null) 107 m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port);
108 { 108 MainServer.AddHttpServer(server);
109 m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); 109 server.Start();
110 MainServer.AddHttpServer(server);
111 server.Start();
112 }
113 } 110 }
114 111
115 base.StartupSpecific(); 112 base.StartupSpecific();
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
131 { 131 {
132 // Start http server 132 // Start http server
133 // Attach xmlrpc handlers 133 // Attach xmlrpc handlers
134 m_log.Info("[XML RPC MODULE]: " + 134// m_log.InfoFormat(
135 "Starting up XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 135// "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.",
136 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); 136// m_remoteDataPort);
137
138 IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort);
137 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 139 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
138 httpServer.Start();
139 } 140 }
140 } 141 }
141 142
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index d471559..7ba0ca8 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -42,42 +42,9 @@ namespace OpenSim.Server.Base
42 { 42 {
43 // Logger 43 // Logger
44 // 44 //
45 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 // The http server instance 47 private uint m_consolePort;
48 //
49 protected BaseHttpServer m_HttpServer = null;
50 protected uint m_Port = 0;
51 protected Dictionary<uint, BaseHttpServer> m_Servers =
52 new Dictionary<uint, BaseHttpServer>();
53 protected uint m_consolePort = 0;
54
55 public IHttpServer HttpServer
56 {
57 get { return m_HttpServer; }
58 }
59
60 public uint DefaultPort
61 {
62 get { return m_Port; }
63 }
64
65 public IHttpServer GetHttpServer(uint port)
66 {
67 m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
68 if (port == m_Port)
69 return HttpServer;
70
71 if (m_Servers.ContainsKey(port))
72 return m_Servers[port];
73
74 m_Servers[port] = new BaseHttpServer(port);
75
76 m_Log.InfoFormat("[SERVER]: Starting new HTTP server on port {0}", port);
77 m_Servers[port].Start();
78
79 return m_Servers[port];
80 }
81 48
82 // Handle all the automagical stuff 49 // Handle all the automagical stuff
83 // 50 //
@@ -94,19 +61,21 @@ namespace OpenSim.Server.Base
94 System.Console.WriteLine("Section 'Network' not found, server can't start"); 61 System.Console.WriteLine("Section 'Network' not found, server can't start");
95 Thread.CurrentThread.Abort(); 62 Thread.CurrentThread.Abort();
96 } 63 }
64
97 uint port = (uint)networkConfig.GetInt("port", 0); 65 uint port = (uint)networkConfig.GetInt("port", 0);
98 66
99 if (port == 0) 67 if (port == 0)
100 { 68 {
101
102 Thread.CurrentThread.Abort(); 69 Thread.CurrentThread.Abort();
103 } 70 }
104 // 71
105 bool ssl_main = networkConfig.GetBoolean("https_main",false); 72 bool ssl_main = networkConfig.GetBoolean("https_main",false);
106 bool ssl_listener = networkConfig.GetBoolean("https_listener",false); 73 bool ssl_listener = networkConfig.GetBoolean("https_listener",false);
107 74
108 m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); 75 m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0);
109 m_Port = port; 76
77 BaseHttpServer httpServer = null;
78
110 // 79 //
111 // This is where to make the servers: 80 // This is where to make the servers:
112 // 81 //
@@ -118,8 +87,7 @@ namespace OpenSim.Server.Base
118 // 87 //
119 if ( !ssl_main ) 88 if ( !ssl_main )
120 { 89 {
121 m_HttpServer = new BaseHttpServer(port); 90 httpServer = new BaseHttpServer(port);
122
123 } 91 }
124 else 92 else
125 { 93 {
@@ -135,10 +103,12 @@ namespace OpenSim.Server.Base
135 System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); 103 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
136 Thread.CurrentThread.Abort(); 104 Thread.CurrentThread.Abort();
137 } 105 }
138 m_HttpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); 106
107 httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass);
139 } 108 }
140 109
141 MainServer.Instance = m_HttpServer; 110 MainServer.AddHttpServer(httpServer);
111 MainServer.Instance = httpServer;
142 112
143 // If https_listener = true, then add an ssl listener on the https_port... 113 // If https_listener = true, then add an ssl listener on the https_port...
144 if ( ssl_listener == true ) { 114 if ( ssl_listener == true ) {
@@ -157,43 +127,24 @@ namespace OpenSim.Server.Base
157 System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); 127 System.Console.WriteLine("Password for X509 certificate is missing, server can't start.");
158 Thread.CurrentThread.Abort(); 128 Thread.CurrentThread.Abort();
159 } 129 }
160 // Add our https_server 130
161 BaseHttpServer server = null; 131 MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass));
162 server = new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass);
163 if (server != null)
164 {
165 m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", https_port);
166 m_Servers.Add(https_port,server);
167 }
168 else
169 System.Console.WriteLine(String.Format("Failed to start HTTPS server on port {0}",https_port));
170 } 132 }
171 } 133 }
172 134
173 protected override void Initialise() 135 protected override void Initialise()
174 { 136 {
175 m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", m_HttpServer.Port); 137 foreach (BaseHttpServer s in MainServer.Servers.Values)
176 m_HttpServer.Start(); 138 s.Start();
177 139
178 if (m_Servers.Count > 0) 140 MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
179 {
180 foreach (BaseHttpServer s in m_Servers.Values)
181 {
182 if (!s.UseSSL)
183 m_Log.InfoFormat("[SERVER]: Starting HTTP server on port {0}", s.Port);
184 else
185 m_Log.InfoFormat("[SERVER]: Starting HTTPS server on port {0}", s.Port);
186
187 s.Start();
188 }
189 }
190 141
191 if (MainConsole.Instance is RemoteConsole) 142 if (MainConsole.Instance is RemoteConsole)
192 { 143 {
193 if (m_consolePort == 0) 144 if (m_consolePort == 0)
194 ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); 145 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
195 else 146 else
196 ((RemoteConsole)MainConsole.Instance).SetServer(GetHttpServer(m_consolePort)); 147 ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
197 } 148 }
198 } 149 }
199 } 150 }
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;
30using System.Reflection; 30using System.Reflection;
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework.Servers;
33using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Server.Handlers.Base; 36using OpenSim.Server.Handlers.Base;
@@ -92,27 +93,24 @@ namespace OpenSim.Server
92 if (parts.Length > 1) 93 if (parts.Length > 1)
93 friendlyName = parts[1]; 94 friendlyName = parts[1];
94 95
95 IHttpServer server = m_Server.HttpServer; 96 IHttpServer server;
96 if (port != 0)
97 server = m_Server.GetHttpServer(port);
98 97
99 if (port != m_Server.DefaultPort && port != 0) 98 if (port != 0)
100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port); 99 server = MainServer.GetHttpServer(port);
101 else 100 else
102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); 101 server = MainServer.Instance;
102
103 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port);
103 104
104 IServiceConnector connector = null; 105 IServiceConnector connector = null;
105 106
106 Object[] modargs = new Object[] { m_Server.Config, server, 107 Object[] modargs = new Object[] { m_Server.Config, server, configName };
107 configName }; 108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, 109
109 modargs);
110 if (connector == null) 110 if (connector == null)
111 { 111 {
112 modargs = new Object[] { m_Server.Config, server }; 112 modargs = new Object[] { m_Server.Config, server };
113 connector = 113 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn, modargs);
114 ServerUtils.LoadPlugin<IServiceConnector>(conn,
115 modargs);
116 } 114 }
117 115
118 if (connector != null) 116 if (connector != null)
@@ -132,4 +130,4 @@ namespace OpenSim.Server
132 return 0; 130 return 0;
133 } 131 }
134 } 132 }
135} 133} \ No newline at end of file