* Fix a locking issue in the EventQueue

trunk
Teravus Ovares 2009-07-31 20:53:35 +00:00
parent 482e907520
commit ae8d3ab22e
1 changed files with 22 additions and 10 deletions

View File

@ -329,19 +329,28 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
public bool HasEvents(UUID agentID)
{
Queue<OSD> queue = TryGetQueue(agentID);
if (queue.Count > 0)
return true;
else
return false;
lock (queue)
{
if (queue.Count > 0)
return true;
else
return false;
}
}
public Hashtable GetEvents(UUID pAgentId, string request)
{
Queue<OSD> queue = TryGetQueue(pAgentId);
OSD element = queue.Dequeue(); // 15s timeout
OSD element;
lock (queue)
{
if (queue.Count == 0)
return NoEvents();
element = queue.Dequeue(); // 15s timeout
}
int thisID = 0;
lock (m_ids)
@ -357,10 +366,13 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
else
{
array.Add(element);
while (queue.Count > 0)
lock (queue)
{
array.Add(queue.Dequeue());
thisID++;
while (queue.Count > 0)
{
array.Add(queue.Dequeue());
thisID++;
}
}
}