improve locking of m_llsdHandlers in BaseHttpServer

bulletsim
Justin Clark-Casey (justincc) 2011-08-22 01:52:08 +01:00
parent 2f1ac1d144
commit 8254116dc6
1 changed files with 32 additions and 30 deletions

View File

@ -285,6 +285,7 @@ namespace OpenSim.Framework.Servers.HttpServer
public List<string> GetLLSDHandlerKeys()
{
lock (m_llsdHandlers)
return new List<string>(m_llsdHandlers.Keys);
}
@ -1107,7 +1108,6 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <returns>true if we have one, false if not</returns>
private bool DoWeHaveALLSDHandler(string path)
{
string[] pathbase = path.Split('/');
string searchquery = "/";
@ -1123,14 +1123,12 @@ namespace OpenSim.Framework.Servers.HttpServer
string bestMatch = null;
lock (m_llsdHandlers)
{
foreach (string pattern in m_llsdHandlers.Keys)
{
if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
{
bestMatch = pattern;
}
}
@ -1143,12 +1141,10 @@ namespace OpenSim.Framework.Servers.HttpServer
if (String.IsNullOrEmpty(bestMatch))
{
return false;
}
else
{
return true;
}
}
@ -1233,6 +1229,8 @@ namespace OpenSim.Framework.Servers.HttpServer
string bestMatch = null;
lock (m_llsdHandlers)
{
foreach (string pattern in m_llsdHandlers.Keys)
{
if (searchquery.ToLower().StartsWith(pattern.ToLower()))
@ -1258,6 +1256,7 @@ namespace OpenSim.Framework.Servers.HttpServer
return true;
}
}
}
private OSDMap GenerateNoLLSDHandlerResponse()
{
@ -1855,6 +1854,8 @@ namespace OpenSim.Framework.Servers.HttpServer
public bool RemoveLLSDHandler(string path, LLSDMethod handler)
{
try
{
lock (m_llsdHandlers)
{
if (handler == m_llsdHandlers[path])
{
@ -1862,6 +1863,7 @@ namespace OpenSim.Framework.Servers.HttpServer
return true;
}
}
}
catch (KeyNotFoundException)
{
// This is an exception to prevent crashing because of invalid code