* Lock http handlers dictionary in other places as well to avoid race conditions

* No adverse effects on a quick multi-machine grid test
0.6.5-rc1
Justin Clarke Casey 2009-03-19 17:07:00 +00:00
parent 1e6056c24b
commit b05be5b06b
1 changed files with 56 additions and 47 deletions

View File

@ -549,26 +549,29 @@ namespace OpenSim.Framework.Servers
string bestMatch = null; 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)) if (String.IsNullOrEmpty(bestMatch))
{ {
HTTPHandler = null; HTTPHandler = null;
return false; return false;
} }
else else
{ {
HTTPHandler = m_HTTPHandlers[bestMatch]; HTTPHandler = m_HTTPHandlers[bestMatch];
return true; 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); //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.. // extra kicker to remove the default XMLRPC login case.. just in case..
if (path == "/") if (path == "/")
return false; return false;
if (String.IsNullOrEmpty(bestMatch)) if (String.IsNullOrEmpty(bestMatch))
{ {
return false; return false;
} }
else else
{ {
return true; return true;
}
} }
} }
@ -1214,32 +1220,35 @@ namespace OpenSim.Framework.Servers
// m_log.DebugFormat( // m_log.DebugFormat(
// "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery); // "[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 (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
// {
if (pattern == "/" && searchquery == "/" || pattern != "/") // You have to specifically register for '/' and to get it, you must specificaly request it
bestMatch = pattern; //
if (pattern == "/" && searchquery == "/" || pattern != "/")
bestMatch = pattern;
}
} }
} }
}
if (String.IsNullOrEmpty(bestMatch)) if (String.IsNullOrEmpty(bestMatch))
{ {
httpHandler = null; httpHandler = null;
return false;
}
else
{
if (bestMatch == "/" && searchquery != "/")
return false; return false;
}
else
{
if (bestMatch == "/" && searchquery != "/")
return false;
httpHandler = m_HTTPHandlers[bestMatch]; httpHandler = m_HTTPHandlers[bestMatch];
return true; return true;
}
} }
} }