diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 113 |
1 files changed, 77 insertions, 36 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ad9e91d..f7d74db 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -40,6 +40,7 @@ using OpenMetaverse; | |||
40 | using OpenMetaverse.Packets; | 40 | using OpenMetaverse.Packets; |
41 | using OpenMetaverse.Imaging; | 41 | using OpenMetaverse.Imaging; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Monitoring; | ||
43 | using OpenSim.Services.Interfaces; | 44 | using OpenSim.Services.Interfaces; |
44 | using OpenSim.Framework.Communications; | 45 | using OpenSim.Framework.Communications; |
45 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
@@ -129,9 +130,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | public bool m_strictAccessControl = true; | 130 | public bool m_strictAccessControl = true; |
130 | public bool m_seeIntoBannedRegion = false; | 131 | public bool m_seeIntoBannedRegion = false; |
131 | public int MaxUndoCount = 5; | 132 | public int MaxUndoCount = 5; |
133 | |||
132 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 134 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
133 | public bool LoginLock = false; | 135 | public bool LoginLock = false; |
134 | public bool LoginsDisabled = true; | 136 | |
135 | public bool StartDisabled = false; | 137 | public bool StartDisabled = false; |
136 | public bool LoadingPrims; | 138 | public bool LoadingPrims; |
137 | public IXfer XferManager; | 139 | public IXfer XferManager; |
@@ -727,6 +729,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
727 | { | 729 | { |
728 | IConfig startupConfig = m_config.Configs["Startup"]; | 730 | IConfig startupConfig = m_config.Configs["Startup"]; |
729 | 731 | ||
732 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | ||
733 | |||
730 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | 734 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
731 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | 735 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
732 | if (!m_useBackup) | 736 | if (!m_useBackup) |
@@ -1229,15 +1233,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1229 | avatar.ControllingClient.SendShutdownConnectionNotice(); | 1233 | avatar.ControllingClient.SendShutdownConnectionNotice(); |
1230 | }); | 1234 | }); |
1231 | 1235 | ||
1236 | // Stop updating the scene objects and agents. | ||
1237 | m_shuttingDown = true; | ||
1238 | |||
1232 | // Wait here, or the kick messages won't actually get to the agents before the scene terminates. | 1239 | // Wait here, or the kick messages won't actually get to the agents before the scene terminates. |
1240 | // We also need to wait to avoid a race condition with the scene update loop which might not yet | ||
1241 | // have checked ShuttingDown. | ||
1233 | Thread.Sleep(500); | 1242 | Thread.Sleep(500); |
1234 | 1243 | ||
1235 | // Stop all client threads. | 1244 | // Stop all client threads. |
1236 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1245 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1237 | 1246 | ||
1238 | // Stop updating the scene objects and agents. | ||
1239 | m_shuttingDown = true; | ||
1240 | |||
1241 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1247 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1242 | EventManager.TriggerSceneShuttingDown(this); | 1248 | EventManager.TriggerSceneShuttingDown(this); |
1243 | 1249 | ||
@@ -1252,6 +1258,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1252 | 1258 | ||
1253 | m_sceneGraph.Close(); | 1259 | m_sceneGraph.Close(); |
1254 | 1260 | ||
1261 | if (PhysicsScene != null) | ||
1262 | { | ||
1263 | PhysicsScene phys = PhysicsScene; | ||
1264 | // remove the physics engine from both Scene and SceneGraph | ||
1265 | PhysicsScene = null; | ||
1266 | phys.Dispose(); | ||
1267 | phys = null; | ||
1268 | } | ||
1269 | |||
1255 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | 1270 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) |
1256 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | 1271 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); |
1257 | 1272 | ||
@@ -1530,7 +1545,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1530 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1545 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1531 | //} | 1546 | //} |
1532 | 1547 | ||
1533 | if (LoginsDisabled && Frame == 20) | 1548 | if (!LoginsEnabled && Frame == 20) |
1534 | { | 1549 | { |
1535 | // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); | 1550 | // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); |
1536 | 1551 | ||
@@ -1538,31 +1553,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
1538 | // this is a rare case where we know we have just went through a long cycle of heap | 1553 | // this is a rare case where we know we have just went through a long cycle of heap |
1539 | // allocations, and there is no more work to be done until someone logs in | 1554 | // allocations, and there is no more work to be done until someone logs in |
1540 | GC.Collect(); | 1555 | GC.Collect(); |
1541 | 1556 | ||
1542 | IConfig startupConfig = m_config.Configs["Startup"]; | 1557 | if (!LoginLock) |
1543 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | ||
1544 | { | 1558 | { |
1545 | // This handles a case of a region having no scripts for the RegionReady module | 1559 | if (!StartDisabled) |
1546 | if (m_sceneGraph.GetActiveScriptsCount() == 0) | ||
1547 | { | ||
1548 | // need to be able to tell these have changed in RegionReady | ||
1549 | LoginLock = false; | ||
1550 | EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); | ||
1551 | } | ||
1552 | |||
1553 | // For RegionReady lockouts | ||
1554 | if (!LoginLock) | ||
1555 | { | 1560 | { |
1556 | m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | 1561 | m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); |
1557 | LoginsDisabled = false; | 1562 | LoginsEnabled = true; |
1558 | } | 1563 | } |
1559 | 1564 | ||
1560 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | 1565 | m_sceneGridService.InformNeighborsThatRegionisUp( |
1566 | RequestModuleInterface<INeighbourService>(), RegionInfo); | ||
1567 | |||
1568 | // Region ready should always be set | ||
1569 | Ready = true; | ||
1561 | } | 1570 | } |
1562 | else | 1571 | else |
1563 | { | 1572 | { |
1564 | StartDisabled = true; | 1573 | // This handles a case of a region having no scripts for the RegionReady module |
1565 | LoginsDisabled = true; | 1574 | if (m_sceneGraph.GetActiveScriptsCount() == 0) |
1575 | { | ||
1576 | // In this case, we leave it to the IRegionReadyModule to enable logins | ||
1577 | |||
1578 | // LoginLock can currently only be set by a region module implementation. | ||
1579 | // If somehow this hasn't been done then the quickest way to bugfix is to see the | ||
1580 | // NullReferenceException | ||
1581 | IRegionReadyModule rrm = RequestModuleInterface<IRegionReadyModule>(); | ||
1582 | rrm.TriggerRegionReady(this); | ||
1583 | } | ||
1566 | } | 1584 | } |
1567 | } | 1585 | } |
1568 | } | 1586 | } |
@@ -3477,25 +3495,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | if (AgentTransactionsModule != null) | 3495 | if (AgentTransactionsModule != null) |
3478 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3496 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3479 | 3497 | ||
3480 | avatar.Close(); | ||
3481 | |||
3482 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3498 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3483 | m_log.Debug("[Scene] The avatar has left the building"); | 3499 | m_log.Debug("[Scene] The avatar has left the building"); |
3484 | } | 3500 | } |
3485 | catch (Exception e) | 3501 | catch (Exception e) |
3486 | { | 3502 | { |
3487 | m_log.Error( | 3503 | m_log.Error( |
3488 | string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e); | 3504 | string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e); |
3489 | } | 3505 | } |
3490 | finally | 3506 | finally |
3491 | { | 3507 | { |
3492 | // Always clean these structures up so that any failure above doesn't cause them to remain in the | 3508 | try |
3493 | // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering | 3509 | { |
3494 | // the same cleanup exception continually. | 3510 | // Always clean these structures up so that any failure above doesn't cause them to remain in the |
3495 | // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE | 3511 | // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering |
3496 | // since this would hide the underlying failure and other associated problems. | 3512 | // the same cleanup exception continually. |
3497 | m_sceneGraph.RemoveScenePresence(agentID); | 3513 | m_sceneGraph.RemoveScenePresence(agentID); |
3498 | m_clientManager.Remove(agentID); | 3514 | m_clientManager.Remove(agentID); |
3515 | |||
3516 | avatar.Close(); | ||
3517 | } | ||
3518 | catch (Exception e) | ||
3519 | { | ||
3520 | m_log.Error( | ||
3521 | string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e); | ||
3522 | } | ||
3499 | } | 3523 | } |
3500 | 3524 | ||
3501 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3525 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
@@ -3609,7 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3609 | agent.startpos | 3633 | agent.startpos |
3610 | ); | 3634 | ); |
3611 | 3635 | ||
3612 | if (LoginsDisabled) | 3636 | if (!LoginsEnabled) |
3613 | { | 3637 | { |
3614 | reason = "Logins Disabled"; | 3638 | reason = "Logins Disabled"; |
3615 | return false; | 3639 | return false; |
@@ -3666,8 +3690,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3666 | // We have a zombie from a crashed session. | 3690 | // We have a zombie from a crashed session. |
3667 | // Or the same user is trying to be root twice here, won't work. | 3691 | // Or the same user is trying to be root twice here, won't work. |
3668 | // Kill it. | 3692 | // Kill it. |
3669 | m_log.DebugFormat( | 3693 | m_log.WarnFormat( |
3670 | "[SCENE]: Zombie scene presence detected for {0} {1} in {2}", | 3694 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", |
3671 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3695 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3672 | 3696 | ||
3673 | sp.ControllingClient.Close(); | 3697 | sp.ControllingClient.Close(); |
@@ -4658,6 +4682,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
4658 | } | 4682 | } |
4659 | 4683 | ||
4660 | /// <summary> | 4684 | /// <summary> |
4685 | /// Gets all the scene presences in this scene. | ||
4686 | /// </summary> | ||
4687 | /// <remarks> | ||
4688 | /// This method will return both root and child scene presences. | ||
4689 | /// | ||
4690 | /// Consider using ForEachScenePresence() or ForEachRootScenePresence() if possible since these will not | ||
4691 | /// involving creating a new List object. | ||
4692 | /// </remarks> | ||
4693 | /// <returns> | ||
4694 | /// A list of the scene presences. Adding or removing from the list will not affect the presences in the scene. | ||
4695 | /// </returns> | ||
4696 | public List<ScenePresence> GetScenePresences() | ||
4697 | { | ||
4698 | return new List<ScenePresence>(m_sceneGraph.GetScenePresences()); | ||
4699 | } | ||
4700 | |||
4701 | /// <summary> | ||
4661 | /// Performs action on all avatars in the scene (root scene presences) | 4702 | /// Performs action on all avatars in the scene (root scene presences) |
4662 | /// Avatars may be an NPC or a 'real' client. | 4703 | /// Avatars may be an NPC or a 'real' client. |
4663 | /// </summary> | 4704 | /// </summary> |