* 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,17 +329,26 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
public bool HasEvents(UUID agentID) public bool HasEvents(UUID agentID)
{ {
Queue<OSD> queue = TryGetQueue(agentID); Queue<OSD> queue = TryGetQueue(agentID);
lock (queue)
{
if (queue.Count > 0) if (queue.Count > 0)
return true; return true;
else else
return false; return false;
}
} }
public Hashtable GetEvents(UUID pAgentId, string request) public Hashtable GetEvents(UUID pAgentId, string request)
{ {
Queue<OSD> queue = TryGetQueue(pAgentId); 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
}
@ -357,12 +366,15 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
else else
{ {
array.Add(element); array.Add(element);
lock (queue)
{
while (queue.Count > 0) while (queue.Count > 0)
{ {
array.Add(queue.Dequeue()); array.Add(queue.Dequeue());
thisID++; thisID++;
} }
} }
}
OSDMap events = new OSDMap(); OSDMap events = new OSDMap();
events.Add("events", array); events.Add("events", array);