Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/Framework/Scenes/Scene.cs
avinationmerge
Melanie 2012-06-08 01:12:37 +01:00
commit 8ebe2cd3da
4 changed files with 78 additions and 87 deletions

View File

@ -644,7 +644,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// an agent cannot teleport back to this region if it has teleported away. // an agent cannot teleport back to this region if it has teleported away.
Thread.Sleep(2000); Thread.Sleep(2000);
sp.Close();
sp.Scene.IncomingCloseAgent(sp.UUID); sp.Scene.IncomingCloseAgent(sp.UUID);
} }
else else

View File

@ -3384,10 +3384,23 @@ namespace OpenSim.Region.Framework.Scenes
// CheckHeartbeat(); // CheckHeartbeat();
bool isChildAgent = false; bool isChildAgent = false;
ScenePresence avatar = GetScenePresence(agentID); ScenePresence avatar = GetScenePresence(agentID);
if (avatar != null)
if (avatar == null)
{
m_log.WarnFormat(
"[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
return;
}
try
{ {
isChildAgent = avatar.IsChildAgent; isChildAgent = avatar.IsChildAgent;
m_log.DebugFormat(
"[SCENE]: Removing {0} agent {1} {2} from {3}",
(isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
// Don't do this to root agents, it's not nice for the viewer // Don't do this to root agents, it's not nice for the viewer
if (closeChildAgents && isChildAgent) if (closeChildAgents && isChildAgent)
{ {
@ -3409,12 +3422,6 @@ namespace OpenSim.Region.Framework.Scenes
avatar.StandUp(); avatar.StandUp();
} }
try
{
m_log.DebugFormat(
"[SCENE]: Removing {0} agent {1} {2} from region {3}",
(isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
m_sceneGraph.removeUserCount(!isChildAgent); m_sceneGraph.removeUserCount(!isChildAgent);
// TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
@ -3426,24 +3433,14 @@ namespace OpenSim.Region.Framework.Scenes
// this method is doing is HORRIBLE!!! // this method is doing is HORRIBLE!!!
avatar.Scene.NeedSceneCacheClear(avatar.UUID); avatar.Scene.NeedSceneCacheClear(avatar.UUID);
if (closeChildAgents && !avatar.IsChildAgent) if (closeChildAgents && !isChildAgent)
{ {
List<ulong> regions = avatar.KnownRegionHandles; List<ulong> regions = avatar.KnownRegionHandles;
regions.Remove(RegionInfo.RegionHandle); regions.Remove(RegionInfo.RegionHandle);
m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
} }
m_log.Debug("[Scene] Beginning ClientClosed");
m_eventManager.TriggerClientClosed(agentID, this);
m_log.Debug("[Scene] Finished ClientClosed");
}
catch (NullReferenceException)
{
// We don't know which count to remove it from
// Avatar is already disposed :/
}
try m_eventManager.TriggerClientClosed(agentID, this);
{
m_eventManager.TriggerOnRemovePresence(agentID); m_eventManager.TriggerOnRemovePresence(agentID);
if (!isChildAgent) if (!isChildAgent)
@ -3473,6 +3470,16 @@ namespace OpenSim.Region.Framework.Scenes
// It's possible for child agents to have transactions if changes are being made cross-border. // It's possible for child agents to have transactions if changes are being made cross-border.
if (AgentTransactionsModule != null) if (AgentTransactionsModule != null)
AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
avatar.Close();
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
m_log.Debug("[Scene] The avatar has left the building");
}
catch (Exception e)
{
m_log.Error(
string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
} }
finally finally
{ {
@ -3485,26 +3492,9 @@ namespace OpenSim.Region.Framework.Scenes
m_clientManager.Remove(agentID); m_clientManager.Remove(agentID);
} }
try
{
avatar.Close();
}
catch (NullReferenceException)
{
//We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
}
catch (Exception e)
{
m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
}
m_log.Debug("[Scene] Done. Firing RemoveCircuit");
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
// CleanDroppedAttachments();
m_log.Debug("[Scene] The avatar has left the building");
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
} }
}
/// <summary> /// <summary>
/// Removes region from an avatar's known region list. This coincides with child agents. For each child agent, there will be a known region entry. /// Removes region from an avatar's known region list. This coincides with child agents. For each child agent, there will be a known region entry.

View File

@ -3598,7 +3598,7 @@ namespace OpenSim.Region.Framework.Scenes
public void Close() public void Close()
{ {
if (!IsChildAgent) if (!IsChildAgent && m_scene.AttachmentsModule != null)
m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
// Clear known regions // Clear known regions

View File

@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
public void TestCloseAgent() public void TestCloseAgent()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // TestHelpers.EnableLogging();
TestScene scene = new SceneHelpers().SetupScene(); TestScene scene = new SceneHelpers().SetupScene();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
@ -114,6 +114,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
// TestHelpers.DisableLogging();
} }
[Test] [Test]