Lock m_requestMap properly to prevent some nasty access errors and the resulting downward spiral

avinationmerge
Tom 2011-05-17 18:44:07 -07:00
parent 6bac16fd88
commit e847d1d83f
1 changed files with 51 additions and 30 deletions

View File

@ -233,8 +233,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
return; return;
} }
lock (m_RequestMap)
{
foreach (UUID req in data.requests.Keys) foreach (UUID req in data.requests.Keys)
m_RequestMap.Remove(req); m_RequestMap.Remove(req);
}
RemoveUrl(data); RemoveUrl(data);
m_UrlMap.Remove(url); m_UrlMap.Remove(url);
@ -242,6 +245,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
} }
public void HttpResponse(UUID request, int status, string body) public void HttpResponse(UUID request, int status, string body)
{
lock (m_RequestMap)
{ {
if (m_RequestMap.ContainsKey(request)) if (m_RequestMap.ContainsKey(request))
{ {
@ -260,8 +265,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
} }
} }
}
public string GetHttpHeader(UUID requestId, string header) public string GetHttpHeader(UUID requestId, string header)
{
lock (m_RequestMap)
{ {
if (m_RequestMap.ContainsKey(requestId)) if (m_RequestMap.ContainsKey(requestId))
{ {
@ -274,6 +282,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
} }
}
return String.Empty; return String.Empty;
} }
@ -294,10 +303,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
RemoveUrl(url.Value); RemoveUrl(url.Value);
removeURLs.Add(url.Key); removeURLs.Add(url.Key);
lock (m_RequestMap)
{
foreach (UUID req in url.Value.requests.Keys) foreach (UUID req in url.Value.requests.Keys)
m_RequestMap.Remove(req); m_RequestMap.Remove(req);
} }
} }
}
foreach (string urlname in removeURLs) foreach (string urlname in removeURLs)
m_UrlMap.Remove(urlname); m_UrlMap.Remove(urlname);
@ -316,10 +328,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
RemoveUrl(url.Value); RemoveUrl(url.Value);
removeURLs.Add(url.Key); removeURLs.Add(url.Key);
lock (m_RequestMap)
{
foreach (UUID req in url.Value.requests.Keys) foreach (UUID req in url.Value.requests.Keys)
m_RequestMap.Remove(req); m_RequestMap.Remove(req);
} }
} }
}
foreach (string urlname in removeURLs) foreach (string urlname in removeURLs)
m_UrlMap.Remove(urlname); m_UrlMap.Remove(urlname);
@ -355,8 +370,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
lock (url) lock (url)
{ {
url.requests.Remove(requestID); url.requests.Remove(requestID);
lock (m_RequestMap)
{
m_RequestMap.Remove(requestID); m_RequestMap.Remove(requestID);
} }
}
return response; return response;
} }
@ -431,8 +449,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
lock (url) lock (url)
{ {
url.requests.Remove(requestID); url.requests.Remove(requestID);
lock (m_RequestMap)
{
m_RequestMap.Remove(requestID); m_RequestMap.Remove(requestID);
} }
}
return response; return response;
} }