aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer
diff options
context:
space:
mode:
authorTom2011-09-04 07:06:36 -0700
committerTom2011-09-04 07:06:36 -0700
commit66dec3b8742eff04fbbcc6e3249fe4ba87986500 (patch)
tree76cc708a821d35fac5cdbbce2de304b47064e732 /OpenSim/Framework/Servers/HttpServer
parentGuard another nullref (diff)
parentFixed BulletSim config files for Linux *.so libraries. (diff)
downloadopensim-SC_OLD-66dec3b8742eff04fbbcc6e3249fe4ba87986500.zip
opensim-SC_OLD-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.gz
opensim-SC_OLD-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.bz2
opensim-SC_OLD-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.xz
Resolve merge commits, stage 1
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs112
1 files changed, 55 insertions, 57 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 460f759..c0d65ac 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -56,7 +56,6 @@ namespace OpenSim.Framework.Servers.HttpServer
56 private volatile int NotSocketErrors = 0; 56 private volatile int NotSocketErrors = 0;
57 public volatile bool HTTPDRunning = false; 57 public volatile bool HTTPDRunning = false;
58 58
59 protected Thread m_workerThread;
60 // protected HttpListener m_httpListener; 59 // protected HttpListener m_httpListener;
61 protected CoolHTTPListener m_httpListener2; 60 protected CoolHTTPListener m_httpListener2;
62 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 61 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
@@ -66,7 +65,6 @@ namespace OpenSim.Framework.Servers.HttpServer
66 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 65 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
67 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); 66 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
68 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); 67 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
69
70 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = 68 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
71 new Dictionary<string, PollServiceEventArgs>(); 69 new Dictionary<string, PollServiceEventArgs>();
72 70
@@ -155,7 +153,8 @@ namespace OpenSim.Framework.Servers.HttpServer
155 153
156 public List<string> GetStreamHandlerKeys() 154 public List<string> GetStreamHandlerKeys()
157 { 155 {
158 return new List<string>(m_streamHandlers.Keys); 156 lock (m_streamHandlers)
157 return new List<string>(m_streamHandlers.Keys);
159 } 158 }
160 159
161 private static string GetHandlerKey(string httpMethod, string path) 160 private static string GetHandlerKey(string httpMethod, string path)
@@ -196,7 +195,8 @@ namespace OpenSim.Framework.Servers.HttpServer
196 195
197 public List<string> GetXmlRpcHandlerKeys() 196 public List<string> GetXmlRpcHandlerKeys()
198 { 197 {
199 return new List<string>(m_rpcHandlers.Keys); 198 lock (m_rpcHandlers)
199 return new List<string>(m_rpcHandlers.Keys);
200 } 200 }
201 201
202 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) 202 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
@@ -218,10 +218,10 @@ namespace OpenSim.Framework.Servers.HttpServer
218 218
219 public List<string> GetHTTPHandlerKeys() 219 public List<string> GetHTTPHandlerKeys()
220 { 220 {
221 return new List<string>(m_HTTPHandlers.Keys); 221 lock (m_HTTPHandlers)
222 return new List<string>(m_HTTPHandlers.Keys);
222 } 223 }
223 224
224
225 public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) 225 public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args)
226 { 226 {
227 bool pollHandlerResult = false; 227 bool pollHandlerResult = false;
@@ -242,10 +242,10 @@ namespace OpenSim.Framework.Servers.HttpServer
242 242
243 public List<string> GetPollServiceHandlerKeys() 243 public List<string> GetPollServiceHandlerKeys()
244 { 244 {
245 return new List<string>(m_pollHandlers.Keys); 245 lock (m_pollHandlers)
246 return new List<string>(m_pollHandlers.Keys);
246 } 247 }
247 248
248
249 // Note that the agent string is provided simply to differentiate 249 // Note that the agent string is provided simply to differentiate
250 // the handlers - it is NOT required to be an actual agent header 250 // the handlers - it is NOT required to be an actual agent header
251 // value. 251 // value.
@@ -266,7 +266,8 @@ namespace OpenSim.Framework.Servers.HttpServer
266 266
267 public List<string> GetAgentHandlerKeys() 267 public List<string> GetAgentHandlerKeys()
268 { 268 {
269 return new List<string>(m_agentHandlers.Keys); 269 lock (m_agentHandlers)
270 return new List<string>(m_agentHandlers.Keys);
270 } 271 }
271 272
272 public bool AddLLSDHandler(string path, LLSDMethod handler) 273 public bool AddLLSDHandler(string path, LLSDMethod handler)
@@ -284,7 +285,8 @@ namespace OpenSim.Framework.Servers.HttpServer
284 285
285 public List<string> GetLLSDHandlerKeys() 286 public List<string> GetLLSDHandlerKeys()
286 { 287 {
287 return new List<string>(m_llsdHandlers.Keys); 288 lock (m_llsdHandlers)
289 return new List<string>(m_llsdHandlers.Keys);
288 } 290 }
289 291
290 public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) 292 public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler)
@@ -404,14 +406,14 @@ namespace OpenSim.Framework.Servers.HttpServer
404 string requestMethod = request.HttpMethod; 406 string requestMethod = request.HttpMethod;
405 string uriString = request.RawUrl; 407 string uriString = request.RawUrl;
406 408
407 string reqnum = "unknown"; 409// string reqnum = "unknown";
408 int tickstart = Environment.TickCount; 410 int tickstart = Environment.TickCount;
409 411
410 try 412 try
411 { 413 {
412 // OpenSim.Framework.WebUtil.OSHeaderRequestID 414 // OpenSim.Framework.WebUtil.OSHeaderRequestID
413 if (request.Headers["opensim-request-id"] != null) 415// if (request.Headers["opensim-request-id"] != null)
414 reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); 416// reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]);
415 //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); 417 //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl);
416 418
417 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); 419 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true);
@@ -746,7 +748,8 @@ namespace OpenSim.Framework.Servers.HttpServer
746 private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) 748 private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
747 { 749 {
748 agentHandler = null; 750 agentHandler = null;
749 try 751
752 lock (m_agentHandlers)
750 { 753 {
751 foreach (IHttpAgentHandler handler in m_agentHandlers.Values) 754 foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
752 { 755 {
@@ -757,9 +760,6 @@ namespace OpenSim.Framework.Servers.HttpServer
757 } 760 }
758 } 761 }
759 } 762 }
760 catch(KeyNotFoundException)
761 {
762 }
763 763
764 return false; 764 return false;
765 } 765 }
@@ -803,9 +803,12 @@ namespace OpenSim.Framework.Servers.HttpServer
803 803
804 XmlRpcMethod method; 804 XmlRpcMethod method;
805 bool methodWasFound; 805 bool methodWasFound;
806 bool keepAlive = false;
806 lock (m_rpcHandlers) 807 lock (m_rpcHandlers)
807 { 808 {
808 methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method); 809 methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method);
810 if (methodWasFound)
811 keepAlive = m_rpcHandlersKeepAlive[methodName];
809 } 812 }
810 813
811 if (methodWasFound) 814 if (methodWasFound)
@@ -824,7 +827,6 @@ namespace OpenSim.Framework.Servers.HttpServer
824 } 827 }
825 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] 828 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
826 829
827
828 try 830 try
829 { 831 {
830 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); 832 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint);
@@ -846,7 +848,7 @@ namespace OpenSim.Framework.Servers.HttpServer
846 } 848 }
847 849
848 // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here 850 // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here
849 response.KeepAlive = m_rpcHandlersKeepAlive[methodName]; 851 response.KeepAlive = keepAlive;
850 } 852 }
851 else 853 else
852 { 854 {
@@ -1106,7 +1108,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1106 /// <returns>true if we have one, false if not</returns> 1108 /// <returns>true if we have one, false if not</returns>
1107 private bool DoWeHaveALLSDHandler(string path) 1109 private bool DoWeHaveALLSDHandler(string path)
1108 { 1110 {
1109
1110 string[] pathbase = path.Split('/'); 1111 string[] pathbase = path.Split('/');
1111 string searchquery = "/"; 1112 string searchquery = "/";
1112 1113
@@ -1122,14 +1123,12 @@ namespace OpenSim.Framework.Servers.HttpServer
1122 1123
1123 string bestMatch = null; 1124 string bestMatch = null;
1124 1125
1125 foreach (string pattern in m_llsdHandlers.Keys) 1126 lock (m_llsdHandlers)
1126 { 1127 {
1127 1128 foreach (string pattern in m_llsdHandlers.Keys)
1128 if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
1129 { 1129 {
1130 1130 if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
1131 bestMatch = pattern; 1131 bestMatch = pattern;
1132
1133 } 1132 }
1134 } 1133 }
1135 1134
@@ -1142,12 +1141,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1142 1141
1143 if (String.IsNullOrEmpty(bestMatch)) 1142 if (String.IsNullOrEmpty(bestMatch))
1144 { 1143 {
1145
1146 return false; 1144 return false;
1147 } 1145 }
1148 else 1146 else
1149 { 1147 {
1150
1151 return true; 1148 return true;
1152 } 1149 }
1153 } 1150 }
@@ -1232,29 +1229,32 @@ namespace OpenSim.Framework.Servers.HttpServer
1232 1229
1233 string bestMatch = null; 1230 string bestMatch = null;
1234 1231
1235 foreach (string pattern in m_llsdHandlers.Keys) 1232 lock (m_llsdHandlers)
1236 { 1233 {
1237 if (searchquery.ToLower().StartsWith(pattern.ToLower())) 1234 foreach (string pattern in m_llsdHandlers.Keys)
1238 { 1235 {
1239 if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) 1236 if (searchquery.ToLower().StartsWith(pattern.ToLower()))
1240 { 1237 {
1241 // You have to specifically register for '/' and to get it, you must specificaly request it 1238 if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
1242 // 1239 {
1243 if (pattern == "/" && searchquery == "/" || pattern != "/") 1240 // You have to specifically register for '/' and to get it, you must specificaly request it
1244 bestMatch = pattern; 1241 //
1242 if (pattern == "/" && searchquery == "/" || pattern != "/")
1243 bestMatch = pattern;
1244 }
1245 } 1245 }
1246 } 1246 }
1247 } 1247
1248 1248 if (String.IsNullOrEmpty(bestMatch))
1249 if (String.IsNullOrEmpty(bestMatch)) 1249 {
1250 { 1250 llsdHandler = null;
1251 llsdHandler = null; 1251 return false;
1252 return false; 1252 }
1253 } 1253 else
1254 else 1254 {
1255 { 1255 llsdHandler = m_llsdHandlers[bestMatch];
1256 llsdHandler = m_llsdHandlers[bestMatch]; 1256 return true;
1257 return true; 1257 }
1258 } 1258 }
1259 } 1259 }
1260 1260
@@ -1816,7 +1816,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1816 1816
1817 //m_log.DebugFormat("[BASE HTTP SERVER]: Removing handler key {0}", handlerKey); 1817 //m_log.DebugFormat("[BASE HTTP SERVER]: Removing handler key {0}", handlerKey);
1818 1818
1819 lock (m_streamHandlers) m_streamHandlers.Remove(handlerKey); 1819 lock (m_streamHandlers)
1820 m_streamHandlers.Remove(handlerKey);
1820 } 1821 }
1821 1822
1822 public void RemoveHTTPHandler(string httpMethod, string path) 1823 public void RemoveHTTPHandler(string httpMethod, string path)
@@ -1848,17 +1849,16 @@ namespace OpenSim.Framework.Servers.HttpServer
1848 1849
1849 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) 1850 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
1850 { 1851 {
1851 try 1852 lock (m_agentHandlers)
1852 { 1853 {
1853 if (handler == m_agentHandlers[agent]) 1854 IHttpAgentHandler foundHandler;
1855
1856 if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler)
1854 { 1857 {
1855 m_agentHandlers.Remove(agent); 1858 m_agentHandlers.Remove(agent);
1856 return true; 1859 return true;
1857 } 1860 }
1858 } 1861 }
1859 catch(KeyNotFoundException)
1860 {
1861 }
1862 1862
1863 return false; 1863 return false;
1864 } 1864 }
@@ -1876,18 +1876,16 @@ namespace OpenSim.Framework.Servers.HttpServer
1876 1876
1877 public bool RemoveLLSDHandler(string path, LLSDMethod handler) 1877 public bool RemoveLLSDHandler(string path, LLSDMethod handler)
1878 { 1878 {
1879 try 1879 lock (m_llsdHandlers)
1880 { 1880 {
1881 if (handler == m_llsdHandlers[path]) 1881 LLSDMethod foundHandler;
1882
1883 if (m_llsdHandlers.TryGetValue(path, out foundHandler) && foundHandler == handler)
1882 { 1884 {
1883 m_llsdHandlers.Remove(path); 1885 m_llsdHandlers.Remove(path);
1884 return true; 1886 return true;
1885 } 1887 }
1886 } 1888 }
1887 catch (KeyNotFoundException)
1888 {
1889 // This is an exception to prevent crashing because of invalid code
1890 }
1891 1889
1892 return false; 1890 return false;
1893 } 1891 }