Protect the responses map with a lock. Also remove ugly "this." type of

member notation.
avinationmerge
Melanie 2012-09-23 23:55:28 +02:00
parent b8119ada59
commit 68ece236a6
2 changed files with 24 additions and 18 deletions

View File

@ -146,14 +146,14 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
m_scene = scene; m_scene = scene;
HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
GetEvents = (x, y, s) => GetEvents = (x, y, s) =>
{ {
lock (responses) lock (responses)
{ {
try try
{ {
return this.responses[x]; return responses[x];
} }
finally finally
{ {
@ -165,15 +165,15 @@ namespace OpenSim.Region.ClientStack.Linden
Request = (x, y) => Request = (x, y) =>
{ {
y["RequestID"] = x.ToString(); y["RequestID"] = x.ToString();
lock (this.requests) lock (requests)
this.requests.Add(y); requests.Add(y);
m_queue.Enqueue(this); m_queue.Enqueue(this);
}; };
NoEvents = (x, y) => NoEvents = (x, y) =>
{ {
lock (this.requests) lock (requests)
{ {
Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
requests.Remove(request); requests.Remove(request);
@ -198,7 +198,7 @@ namespace OpenSim.Region.ClientStack.Linden
try try
{ {
lock (this.requests) lock (requests)
{ {
request = requests[0]; request = requests[0];
requests.RemoveAt(0); requests.RemoveAt(0);
@ -221,8 +221,10 @@ namespace OpenSim.Region.ClientStack.Linden
response["content_type"] = "text/plain"; response["content_type"] = "text/plain";
response["keepalive"] = false; response["keepalive"] = false;
response["reusecontext"] = false; response["reusecontext"] = false;
lock (responses) lock (responses)
responses[requestID] = response; responses[requestID] = response;
return; return;
} }

View File

@ -144,31 +144,34 @@ namespace OpenSim.Region.ClientStack.Linden
public PollServiceInventoryEventArgs(UUID pId) : public PollServiceInventoryEventArgs(UUID pId) :
base(null, null, null, null, pId, 30000) base(null, null, null, null, pId, 30000)
{ {
HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
GetEvents = (x, y, s) => GetEvents = (x, y, s) =>
{
lock (responses)
{ {
try try
{ {
return this.responses[x]; return responses[x];
} }
finally finally
{ {
responses.Remove(x); responses.Remove(x);
} }
}
}; };
Request = (x, y) => Request = (x, y) =>
{ {
y["RequestID"] = x.ToString(); y["RequestID"] = x.ToString();
lock (this.requests) lock (requests)
this.requests.Add(y); requests.Add(y);
m_queue.Enqueue(this); m_queue.Enqueue(this);
}; };
NoEvents = (x, y) => NoEvents = (x, y) =>
{ {
lock (this.requests) lock (requests)
{ {
Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
requests.Remove(request); requests.Remove(request);
@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden
try try
{ {
lock (this.requests) lock (requests)
{ {
request = requests[0]; request = requests[0];
requests.RemoveAt(0); requests.RemoveAt(0);
@ -214,6 +217,7 @@ namespace OpenSim.Region.ClientStack.Linden
response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null);
lock (responses)
responses[requestID] = response; responses[requestID] = response;
} }
} }