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,9 +233,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
return; return;
} }
foreach (UUID req in data.requests.Keys) lock (m_RequestMap)
m_RequestMap.Remove(req); {
foreach (UUID req in data.requests.Keys)
m_RequestMap.Remove(req);
}
RemoveUrl(data); RemoveUrl(data);
m_UrlMap.Remove(url); m_UrlMap.Remove(url);
} }
@ -243,36 +246,42 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void HttpResponse(UUID request, int status, string body) public void HttpResponse(UUID request, int status, string body)
{ {
if (m_RequestMap.ContainsKey(request)) lock (m_RequestMap)
{ {
UrlData urlData = m_RequestMap[request]; if (m_RequestMap.ContainsKey(request))
if (!urlData.requests[request].responseSent)
{ {
urlData.requests[request].responseCode = status; UrlData urlData = m_RequestMap[request];
urlData.requests[request].responseBody = body; if (!urlData.requests[request].responseSent)
//urlData.requests[request].ev.Set(); {
urlData.requests[request].requestDone = true; urlData.requests[request].responseCode = status;
urlData.requests[request].responseSent = true; urlData.requests[request].responseBody = body;
//urlData.requests[request].ev.Set();
urlData.requests[request].requestDone = true;
urlData.requests[request].responseSent = true;
}
}
else
{
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
} }
}
else
{
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)
{ {
if (m_RequestMap.ContainsKey(requestId)) lock (m_RequestMap)
{ {
UrlData urlData=m_RequestMap[requestId]; if (m_RequestMap.ContainsKey(requestId))
string value; {
if (urlData.requests[requestId].headers.TryGetValue(header,out value)) UrlData urlData = m_RequestMap[requestId];
return value; string value;
} if (urlData.requests[requestId].headers.TryGetValue(header, out value))
else return value;
{ }
m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); else
{
m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
}
} }
return String.Empty; return String.Empty;
} }
@ -294,8 +303,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
RemoveUrl(url.Value); RemoveUrl(url.Value);
removeURLs.Add(url.Key); removeURLs.Add(url.Key);
foreach (UUID req in url.Value.requests.Keys) lock (m_RequestMap)
m_RequestMap.Remove(req); {
foreach (UUID req in url.Value.requests.Keys)
m_RequestMap.Remove(req);
}
} }
} }
@ -316,8 +328,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
RemoveUrl(url.Value); RemoveUrl(url.Value);
removeURLs.Add(url.Key); removeURLs.Add(url.Key);
foreach (UUID req in url.Value.requests.Keys) lock (m_RequestMap)
m_RequestMap.Remove(req); {
foreach (UUID req in url.Value.requests.Keys)
m_RequestMap.Remove(req);
}
} }
} }
@ -355,7 +370,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
lock (url) lock (url)
{ {
url.requests.Remove(requestID); url.requests.Remove(requestID);
m_RequestMap.Remove(requestID); lock (m_RequestMap)
{
m_RequestMap.Remove(requestID);
}
} }
return response; return response;
@ -431,7 +449,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
lock (url) lock (url)
{ {
url.requests.Remove(requestID); url.requests.Remove(requestID);
m_RequestMap.Remove(requestID); lock (m_RequestMap)
{
m_RequestMap.Remove(requestID);
}
} }
return response; return response;