From b05be5b06bc39cb364c6deb5b7ceaee34a61914c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 19 Mar 2009 17:07:00 +0000 Subject: * Lock http handlers dictionary in other places as well to avoid race conditions * No adverse effects on a quick multi-machine grid test --- OpenSim/Framework/Servers/BaseHttpServer.cs | 103 +++++++++++++++------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index efa71f2..1b34209 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -549,26 +549,29 @@ namespace OpenSim.Framework.Servers string bestMatch = null; - foreach (string pattern in m_HTTPHandlers.Keys) + lock (m_HTTPHandlers) { - if (handlerKey.StartsWith(pattern)) + foreach (string pattern in m_HTTPHandlers.Keys) { - if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) + if (handlerKey.StartsWith(pattern)) { - bestMatch = pattern; + if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) + { + bestMatch = pattern; + } } } - } - if (String.IsNullOrEmpty(bestMatch)) - { - HTTPHandler = null; - return false; - } - else - { - HTTPHandler = m_HTTPHandlers[bestMatch]; - return true; + if (String.IsNullOrEmpty(bestMatch)) + { + HTTPHandler = null; + return false; + } + else + { + HTTPHandler = m_HTTPHandlers[bestMatch]; + return true; + } } } @@ -925,25 +928,28 @@ namespace OpenSim.Framework.Servers //m_log.DebugFormat("[BASE HTTP HANDLER]: Checking if we have an HTTP handler for {0}", searchquery); - foreach (string pattern in m_HTTPHandlers.Keys) + lock (m_HTTPHandlers) { - if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) + foreach (string pattern in m_HTTPHandlers.Keys) { - bestMatch = pattern; + if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) + { + bestMatch = pattern; + } } - } - // extra kicker to remove the default XMLRPC login case.. just in case.. - if (path == "/") - return false; + // extra kicker to remove the default XMLRPC login case.. just in case.. + if (path == "/") + return false; - if (String.IsNullOrEmpty(bestMatch)) - { - return false; - } - else - { - return true; + if (String.IsNullOrEmpty(bestMatch)) + { + return false; + } + else + { + return true; + } } } @@ -1214,32 +1220,35 @@ namespace OpenSim.Framework.Servers // m_log.DebugFormat( // "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery); - foreach (string pattern in m_HTTPHandlers.Keys) + lock (m_HTTPHandlers) { - if (searchquery.ToLower().StartsWith(pattern.ToLower())) + foreach (string pattern in m_HTTPHandlers.Keys) { - if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) + if (searchquery.ToLower().StartsWith(pattern.ToLower())) { - // You have to specifically register for '/' and to get it, you must specificaly request it - // - if (pattern == "/" && searchquery == "/" || pattern != "/") - bestMatch = pattern; + if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) + { + // You have to specifically register for '/' and to get it, you must specificaly request it + // + if (pattern == "/" && searchquery == "/" || pattern != "/") + bestMatch = pattern; + } } - } - } + } - if (String.IsNullOrEmpty(bestMatch)) - { - httpHandler = null; - return false; - } - else - { - if (bestMatch == "/" && searchquery != "/") + if (String.IsNullOrEmpty(bestMatch)) + { + httpHandler = null; return false; + } + else + { + if (bestMatch == "/" && searchquery != "/") + return false; - httpHandler = m_HTTPHandlers[bestMatch]; - return true; + httpHandler = m_HTTPHandlers[bestMatch]; + return true; + } } } -- cgit v1.1