From b7d596a6af51bea7dba642cdc768ac5ff77af5f3 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 28 Nov 2007 06:18:07 +0000 Subject: * Restaring the sim works fine in grid mode now. Sims announce themselves to their neighbors when they start up. Neighbors get this message and tell their agents that there's a new sim up. * Certain unrecoverable physics based crashes in ODE are now hooked up to the 'restart the sim' routine. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 53 ++++++++++++++++++++-- OpenSim/Region/Environment/Scenes/Scene.cs | 21 +++++++-- .../Scenes/SceneCommunicationService.cs | 14 +++++- OpenSim/Region/Environment/Scenes/SceneManager.cs | 2 +- 4 files changed, 80 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 8f7cbee..c1acde4 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -11,8 +11,14 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { + public delegate void PhysicsCrash(); + public class InnerScene { + #region Events + public event PhysicsCrash UnRecoverableError; + #endregion + #region Fields public Dictionary ScenePresences; public Dictionary SceneObjects; @@ -26,17 +32,47 @@ namespace OpenSim.Region.Environment.Scenes internal object m_syncRoot = new object(); - public PhysicsScene PhyScene; + public PhysicsScene _PhyScene; #endregion public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) { + m_parentScene = parent; m_regInfo = regInfo; PermissionsMngr = permissionsMngr; QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); QuadTree.Subdivide(); QuadTree.Subdivide(); + + + } + public PhysicsScene PhyScene + { + get + { return _PhyScene; } + set + { + // If we're not doing the initial set + // Then we've got to remove the previous + // event handler + try + { + _PhyScene.OnPhysicsCrash -= physicsBasedCrash; + } + catch (System.NullReferenceException) + { + // This occurs when storing to _PhyScene the first time. + // Is there a better way to check the event handler before + // getting here + // This can be safely ignored. We're setting the first inital + // there are no event handler's registered. + } + + _PhyScene = value; + + _PhyScene.OnPhysicsCrash += physicsBasedCrash; + } } public void Close() @@ -55,9 +91,9 @@ namespace OpenSim.Region.Environment.Scenes // PhysX does this (runs in the background). - if (PhyScene.IsThreaded) + if (_PhyScene.IsThreaded) { - PhyScene.GetResults(); + _PhyScene.GetResults(); } } @@ -75,7 +111,7 @@ namespace OpenSim.Region.Environment.Scenes { lock (m_syncRoot) { - PhyScene.Simulate((float)elapsed); + _PhyScene.Simulate((float)elapsed); } } @@ -338,6 +374,15 @@ namespace OpenSim.Region.Environment.Scenes #region Other Methods + + public void physicsBasedCrash() + { + if (UnRecoverableError != null) + { + UnRecoverableError(); + } + } + public LLUUID ConvertLocalIDToFullID(uint localID) { SceneObjectGroup group = GetGroupByPrim(localID); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bdafce8..1359bd2 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -232,6 +232,15 @@ namespace OpenSim.Region.Environment.Scenes m_permissionManager.Initialise(this); m_innerScene = new InnerScene(this, m_regInfo, m_permissionManager); + + // If the Inner scene has an Unrecoverable error, restart this sim. + // Currently the only thing that causes it to happen is two kinds of specific + // Physics based crashes. + // + // Out of memory + // Operating system has killed the plugin + m_innerScene.UnRecoverableError += restartNOW; + m_sceneXmlLoader = new SceneXmlLoader(this, m_innerScene, m_regInfo); RegisterDefaultSceneEvents(); @@ -315,13 +324,17 @@ namespace OpenSim.Region.Environment.Scenes { t_restartTimer.Stop(); t_restartTimer.AutoReset = false; - MainLog.Instance.Error("REGION", "Closing"); - Close(); - MainLog.Instance.Error("REGION", "Firing Region Restart Message"); - base.Restart(0); + restartNOW(); } } + public void restartNOW() + { + MainLog.Instance.Error("REGION", "Closing"); + Close(); + MainLog.Instance.Error("REGION", "Firing Region Restart Message"); + base.Restart(0); + } public void restart_Notify_Wait_Elapsed(object sender, ElapsedEventArgs e) { m_restartWaitTimer.Stop(); diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 9a83710..892bf81 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -171,6 +171,18 @@ namespace OpenSim.Region.Environment.Scenes } } + public void RequestNeighbors(RegionInfo region) + { + List neighbours = + m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + //IPEndPoint blah = new IPEndPoint(); + + //blah.Address = region.RemotingAddress; + //blah.Port = region.RemotingPort; + + + } + /// /// /// @@ -311,7 +323,7 @@ namespace OpenSim.Region.Environment.Scenes public void InformNeighborsThatRegionisUp(RegionInfo region) { //MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); - bool val = m_commsProvider.InterRegion.RegionUp(region); + bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, LLVector3 position, bool isPhysical) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index eba45fc..ed33bf7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -216,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes public void RestartCurrentScene() { - ForEachCurrentScene(delegate(Scene scene) { scene.Restart(15); }); + ForEachCurrentScene(delegate(Scene scene) { scene.restartNOW(); }); } -- cgit v1.1