From 8c0b9080a4fb013d559966fc8c8175fb16162c2d Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 18 Feb 2013 21:09:14 +0100
Subject: Fix an issue where the viewer would request the seed cap before there
was a handler for it.
---
OpenSim/Capabilities/Caps.cs | 13 ++++++
.../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 3 ++
.../Framework/Caps/CapabilitiesModule.cs | 41 +++++++++++-------
.../Framework/Interfaces/ICapabilitiesModule.cs | 8 ++--
OpenSim/Region/Framework/Scenes/Scene.cs | 50 +++++++++++++++-------
5 files changed, 81 insertions(+), 34 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs
index bc6f6f9..241fef3 100644
--- a/OpenSim/Capabilities/Caps.cs
+++ b/OpenSim/Capabilities/Caps.cs
@@ -30,6 +30,7 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
+using System.Threading;
using log4net;
using Nini.Config;
using OpenMetaverse;
@@ -68,6 +69,7 @@ namespace OpenSim.Framework.Capabilities
private IHttpServer m_httpListener;
private UUID m_agentID;
private string m_regionName;
+ private ManualResetEvent m_capsActive = new ManualResetEvent(false);
public UUID AgentID
{
@@ -171,5 +173,16 @@ namespace OpenSim.Framework.Capabilities
}
}
}
+
+ public void Activate()
+ {
+ m_capsActive.Set();
+ }
+
+ public bool WaitForActivation()
+ {
+ // Wait for 30s. If that elapses, return false and run without caps
+ return m_capsActive.WaitOne(30000);
+ }
}
}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 2bb3d38..248eab6 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -343,6 +343,9 @@ namespace OpenSim.Region.ClientStack.Linden
m_log.DebugFormat(
"[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID);
+ if (!m_HostCapsObj.WaitForActivation())
+ return string.Empty;
+
if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint))
{
m_log.WarnFormat(
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 7f30e5a..2eb9bfb 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Framework
///
/// Each agent has its own capabilities handler.
///
- protected Dictionary m_capsObjects = new Dictionary();
+ protected Dictionary m_capsObjects = new Dictionary();
protected Dictionary capsPaths = new Dictionary();
protected Dictionary> childrenSeeds
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.Framework
get { return null; }
}
- public void CreateCaps(UUID agentId)
+ public void CreateCaps(UUID agentId, uint circuitCode)
{
int flags = m_scene.GetUserFlags(agentId);
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
@@ -108,9 +108,9 @@ namespace OpenSim.Region.CoreModules.Framework
String capsObjectPath = GetCapsPath(agentId);
- if (m_capsObjects.ContainsKey(agentId))
+ if (m_capsObjects.ContainsKey(circuitCode))
{
- Caps oldCaps = m_capsObjects[agentId];
+ Caps oldCaps = m_capsObjects[circuitCode];
m_log.DebugFormat(
"[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
@@ -125,12 +125,12 @@ namespace OpenSim.Region.CoreModules.Framework
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
- m_capsObjects[agentId] = caps;
+ m_capsObjects[circuitCode] = caps;
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
}
- public void RemoveCaps(UUID agentId)
+ public void RemoveCaps(UUID agentId, uint circuitCode)
{
if (childrenSeeds.ContainsKey(agentId))
{
@@ -139,11 +139,11 @@ namespace OpenSim.Region.CoreModules.Framework
lock (m_capsObjects)
{
- if (m_capsObjects.ContainsKey(agentId))
+ if (m_capsObjects.ContainsKey(circuitCode))
{
- m_capsObjects[agentId].DeregisterHandlers();
- m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]);
- m_capsObjects.Remove(agentId);
+ m_capsObjects[circuitCode].DeregisterHandlers();
+ m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[circuitCode]);
+ m_capsObjects.Remove(circuitCode);
}
else
{
@@ -154,19 +154,30 @@ namespace OpenSim.Region.CoreModules.Framework
}
}
- public Caps GetCapsForUser(UUID agentId)
+ public Caps GetCapsForUser(uint circuitCode)
{
lock (m_capsObjects)
{
- if (m_capsObjects.ContainsKey(agentId))
+ if (m_capsObjects.ContainsKey(circuitCode))
{
- return m_capsObjects[agentId];
+ return m_capsObjects[circuitCode];
}
}
return null;
}
+ public void ActivateCaps(uint circuitCode)
+ {
+ lock (m_capsObjects)
+ {
+ if (m_capsObjects.ContainsKey(circuitCode))
+ {
+ m_capsObjects[circuitCode].Activate();
+ }
+ }
+ }
+
public void SetAgentCapsSeeds(AgentCircuitData agent)
{
capsPaths[agent.AgentID] = agent.CapsPath;
@@ -237,9 +248,9 @@ namespace OpenSim.Region.CoreModules.Framework
StringBuilder caps = new StringBuilder();
caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
- foreach (KeyValuePair kvp in m_capsObjects)
+ foreach (KeyValuePair kvp in m_capsObjects)
{
- caps.AppendFormat("** User {0}:\n", kvp.Key);
+ caps.AppendFormat("** Circuit {0}:\n", kvp.Key);
for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false).GetEnumerator(); kvp2.MoveNext(); )
{
diff --git a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs
index 522c82d..30d404e 100644
--- a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs
@@ -40,19 +40,19 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- void CreateCaps(UUID agentId);
+ void CreateCaps(UUID agentId, uint circuitCode);
///
/// Remove the caps handler for a given agent.
///
///
- void RemoveCaps(UUID agentId);
+ void RemoveCaps(UUID agentId, uint circuitCode);
///
/// Will return null if the agent doesn't have a caps handler registered
///
///
- Caps GetCapsForUser(UUID agentId);
+ Caps GetCapsForUser(uint circuitCode);
void SetAgentCapsSeeds(AgentCircuitData agent);
@@ -65,5 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces
void DropChildSeed(UUID agentID, ulong handle);
string GetCapsPath(UUID agentId);
+
+ void ActivateCaps(uint circuitCode);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e58aadc..7fcbed4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3622,7 +3622,7 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
// unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
if (closeChildAgents && CapsModule != null)
- CapsModule.RemoveCaps(agentID);
+ CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
// // this method is doing is HORRIBLE!!!
@@ -3853,20 +3853,36 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
-
ScenePresence sp = GetScenePresence(agent.AgentID);
- if (sp != null && !sp.IsChildAgent)
+ // If we have noo presence here or if that presence is a zombie root
+ // presence that will be kicled, we need a new CAPS object.
+ if (sp == null || (sp != null && !sp.IsChildAgent))
{
- // We have a zombie from a crashed session.
- // Or the same user is trying to be root twice here, won't work.
- // Kill it.
- m_log.WarnFormat(
- "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
- sp.Name, sp.UUID, RegionInfo.RegionName);
+ if (CapsModule != null)
+ {
+ lock (agent)
+ {
+ CapsModule.SetAgentCapsSeeds(agent);
+ CapsModule.CreateCaps(agent.AgentID, agent.circuitcode);
+ }
+ }
+ }
+
+ if (sp != null)
+ {
+ if (!sp.IsChildAgent)
+ {
+ // We have a zombie from a crashed session.
+ // Or the same user is trying to be root twice here, won't work.
+ // Kill it.
+ m_log.WarnFormat(
+ "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
+ sp.Name, sp.UUID, RegionInfo.RegionName);
- sp.ControllingClient.Close(true, true);
- sp = null;
+ sp.ControllingClient.Close(true, true);
+ sp = null;
+ }
}
lock (agent)
@@ -3907,7 +3923,9 @@ namespace OpenSim.Region.Framework.Scenes
if (vialogin || (!m_seeIntoBannedRegion))
{
if (!AuthorizeUser(agent, out reason))
+ {
return false;
+ }
}
}
catch (Exception e)
@@ -3922,11 +3940,6 @@ namespace OpenSim.Region.Framework.Scenes
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode);
- if (CapsModule != null)
- {
- CapsModule.SetAgentCapsSeeds(agent);
- CapsModule.CreateCaps(agent.AgentID);
- }
}
else
{
@@ -3952,6 +3965,11 @@ namespace OpenSim.Region.Framework.Scenes
agent.teleportFlags = teleportFlags;
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
+ if (CapsModule != null)
+ {
+ CapsModule.ActivateCaps(agent.circuitcode);
+ }
+
if (vialogin)
{
// CleanDroppedAttachments();
--
cgit v1.1