From 7691be377a49ec1d0e359b081d6b51c439920265 Mon Sep 17 00:00:00 2001
From: diva
Date: Fri, 19 Dec 2008 20:31:32 +0000
Subject: Fix for more child agent mismanagement (like #2846). On enqueueing
events, we should not be creating new queues; if the queue doesn't exist --
too bad, event is dropped. That tends to happen just after the client is
closed, and the EQ also closed. If someone places an event in that queue
after that, that event should be dropped instead of creating a new, erroneous
queue.
---
.../Modules/Framework/EventQueueGetModule.cs | 49 +++++++++++++++++++---
1 file changed, 44 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/Framework')
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
index f1f70ff..436231b 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
@@ -136,7 +136,12 @@ namespace OpenSim.Region.Environment.Modules.Framework
}
#endregion
- private BlockingLLSDQueue GetQueue(UUID agentId)
+ ///
+ /// Always returns a valid queue
+ ///
+ ///
+ ///
+ private BlockingLLSDQueue TryGetQueue(UUID agentId)
{
lock (queues)
{
@@ -150,15 +155,34 @@ namespace OpenSim.Region.Environment.Modules.Framework
}
}
-
+ ///
+ /// May return a null queue
+ ///
+ ///
+ ///
+ private BlockingLLSDQueue GetQueue(UUID agentId)
+ {
+ lock (queues)
+ {
+ if (queues.ContainsKey(agentId))
+ {
+ return queues[agentId];
+ }
+ else
+ return null;
+ }
+ }
+
#region IEventQueue Members
+
public bool Enqueue(OSD ev, UUID avatarID)
{
m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName);
try
{
BlockingLLSDQueue queue = GetQueue(avatarID);
- queue.Enqueue(ev);
+ if (queue != null)
+ queue.Enqueue(ev);
} catch(NullReferenceException e)
{
m_log.Debug("[EVENTQUEUE] Caught exception: " + e);
@@ -166,11 +190,26 @@ namespace OpenSim.Region.Environment.Modules.Framework
}
return true;
}
+
#endregion
private void OnNewClient(IClientAPI client)
{
- m_log.DebugFormat("[EVENTQUEUE]: New client {0} detected in region {1}", client.AgentId, m_scene.RegionInfo.RegionName);
+ //m_log.DebugFormat("[EVENTQUEUE]: New client {0} detected in region {1}", client.AgentId, m_scene.RegionInfo.RegionName);
+ //lock (queues)
+ //{
+ // if (queues.ContainsKey(client.AgentId))
+ // {
+ // m_log.DebugFormat("[EVENTQUEUE]: Removing old queue for agent {0} in region {1}", client.AgentId,
+ // m_scene.RegionInfo.RegionName);
+ // queues.Remove(client.AgentId);
+ // }
+
+ // m_log.DebugFormat("[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", client.AgentId,
+ // m_scene.RegionInfo.RegionName);
+ // queues[client.AgentId] = new BlockingLLSDQueue();
+ //}
+
client.OnLogout += ClientClosed;
}
@@ -317,7 +356,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
// }
- BlockingLLSDQueue queue = GetQueue(agentID);
+ BlockingLLSDQueue queue = TryGetQueue(agentID);
OSD element = queue.Dequeue(15000); // 15s timeout
Hashtable responsedata = new Hashtable();
--
cgit v1.1