aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-15 02:03:50 +0100
committerJustin Clark-Casey (justincc)2012-06-15 02:03:50 +0100
commit257b1b517dec58bf902bac63bc7ab7080286d415 (patch)
treee0528b6032f1403cbcd03a216b527c565a2ac777 /OpenSim/Framework
parentminor: Tell user the current debug http level if "debug http" console command... (diff)
downloadopensim-SC_OLD-257b1b517dec58bf902bac63bc7ab7080286d415.zip
opensim-SC_OLD-257b1b517dec58bf902bac63bc7ab7080286d415.tar.gz
opensim-SC_OLD-257b1b517dec58bf902bac63bc7ab7080286d415.tar.bz2
opensim-SC_OLD-257b1b517dec58bf902bac63bc7ab7080286d415.tar.xz
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
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs8
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs64
2 files changed, 61 insertions, 11 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
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 /// <summary>
57 /// Control the printing of certain debug messages.
58 /// </summary>
59 /// <remarks>
60 /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data.
61 /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data.
62 /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged.
63 /// </remarks>
64 public int DebugLevel { get; set; } 56 public int DebugLevel { get; set; }
65 57
66 private volatile int NotSocketErrors = 0; 58 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 @@
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;
@@ -40,13 +41,20 @@ namespace OpenSim.Framework.Servers
40 private static BaseHttpServer instance = null; 41 private static BaseHttpServer instance = null;
41 private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); 42 private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>();
42 43
44 /// <summary>
45 /// Control the printing of certain debug messages.
46 /// </summary>
47 /// <remarks>
48 /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data.
49 /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data.
50 /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged.
51 /// </remarks>
43 public static int DebugLevel 52 public static int DebugLevel
44 { 53 {
45 get { return s_debugLevel; } 54 get { return s_debugLevel; }
46 set 55 set
47 { 56 {
48 s_debugLevel = value; 57 s_debugLevel = value;
49 Instance.DebugLevel = s_debugLevel;
50 58
51 lock (m_Servers) 59 lock (m_Servers)
52 foreach (BaseHttpServer server in m_Servers.Values) 60 foreach (BaseHttpServer server in m_Servers.Values)
@@ -56,20 +64,70 @@ namespace OpenSim.Framework.Servers
56 64
57 private static int s_debugLevel; 65 private static int s_debugLevel;
58 66
67 /// <summary>
68 /// Set the main HTTP server instance.
69 /// </summary>
70 /// <remarks>
71 /// This will be used to register all handlers that listen to the default port.
72 /// </remarks>
73 /// <exception cref='Exception'>
74 /// Thrown if the HTTP server has not already been registered via AddHttpServer()
75 /// </exception>
59 public static BaseHttpServer Instance 76 public static BaseHttpServer Instance
60 { 77 {
61 get { return instance; } 78 get { return instance; }
62 set { instance = value; } 79
80 set
81 {
82 lock (m_Servers)
83 if (!m_Servers.ContainsValue(value))
84 throw new Exception("HTTP server must already have been registered to be set as the main instance");
85
86 instance = value;
87 }
63 } 88 }
64 89
65 /// <summary> 90 /// <summary>
66 /// Add an already started HTTP server to the collection of known servers. 91 /// Register an already started HTTP server to the collection of known servers.
67 /// </summary> 92 /// </summary>
68 /// <param name='server'></param> 93 /// <param name='server'></param>
69 public static void AddHttpServer(BaseHttpServer server) 94 public static void AddHttpServer(BaseHttpServer server)
70 { 95 {
71 lock (m_Servers) 96 lock (m_Servers)
97 {
98 if (m_Servers.ContainsKey(server.Port))
99 throw new Exception(string.Format("HTTP server for port {0} already exists.", server.Port));
100
72 m_Servers.Add(server.Port, server); 101 m_Servers.Add(server.Port, server);
102 }
103 }
104
105 /// <summary>
106 /// Removes the http server listening on the given port.
107 /// </summary>
108 /// <remarks>
109 /// It is the responsibility of the caller to do clean up.
110 /// </remarks>
111 /// <param name='port'></param>
112 /// <returns></returns>
113 public static bool RemoveHttpServer(uint port)
114 {
115 lock (m_Servers)
116 return m_Servers.Remove(port);
117 }
118
119 /// <summary>
120 /// Does this collection of servers contain one with the given port?
121 /// </summary>
122 /// <remarks>
123 /// Unlike GetHttpServer, this will not instantiate a server if one does not exist on that port.
124 /// </remarks>
125 /// <param name='port'></param>
126 /// <returns>true if a server with the given port is registered, false otherwise.</returns>
127 public static bool ContainsHttpServer(uint port)
128 {
129 lock (m_Servers)
130 return m_Servers.ContainsKey(port);
73 } 131 }
74 132
75 /// <summary> 133 /// <summary>