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

View File

@ -144,31 +144,34 @@ namespace OpenSim.Region.ClientStack.Linden
public PollServiceInventoryEventArgs(UUID pId) :
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) =>
{
lock (responses)
{
try
{
return this.responses[x];
return responses[x];
}
finally
{
responses.Remove(x);
}
}
};
Request = (x, y) =>
{
y["RequestID"] = x.ToString();
lock (this.requests)
this.requests.Add(y);
lock (requests)
requests.Add(y);
m_queue.Enqueue(this);
};
NoEvents = (x, y) =>
{
lock (this.requests)
lock (requests)
{
Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
requests.Remove(request);
@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden
try
{
lock (this.requests)
lock (requests)
{
request = requests[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);
lock (responses)
responses[requestID] = response;
}
}