diff options
author | Justin Clark-Casey (justincc) | 2012-11-23 02:22:30 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-11-23 02:22:30 +0000 |
commit | 8c8c8a00a47b61fcfd4a500ac8f13aa1aafaad26 (patch) | |
tree | fbaa01d3747e741d3384603b77c72813b2aa8b86 /OpenSim/Region | |
parent | Add regression test for checking scene close when SceneManager is asked to close (diff) | |
download | opensim-SC_OLD-8c8c8a00a47b61fcfd4a500ac8f13aa1aafaad26.zip opensim-SC_OLD-8c8c8a00a47b61fcfd4a500ac8f13aa1aafaad26.tar.gz opensim-SC_OLD-8c8c8a00a47b61fcfd4a500ac8f13aa1aafaad26.tar.bz2 opensim-SC_OLD-8c8c8a00a47b61fcfd4a500ac8f13aa1aafaad26.tar.xz |
Fix problem where restarting the currently selected region would stop various console commands (e.g. "show users") from working.
This was because the "currently selected" scene reference was being left as the dead scene instead of the restarted Scene object.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Application/OpenSim.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 46 |
4 files changed, 51 insertions, 36 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 17b2167..cffbb3b 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -664,12 +664,20 @@ namespace OpenSim | |||
664 | 664 | ||
665 | if (!SceneManager.TrySetCurrentScene(newRegionName)) | 665 | if (!SceneManager.TrySetCurrentScene(newRegionName)) |
666 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); | 666 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); |
667 | else | ||
668 | RefreshPrompt(); | ||
667 | } | 669 | } |
668 | else | 670 | else |
669 | { | 671 | { |
670 | MainConsole.Instance.Output("Usage: change region <region name>"); | 672 | MainConsole.Instance.Output("Usage: change region <region name>"); |
671 | } | 673 | } |
674 | } | ||
672 | 675 | ||
676 | /// <summary> | ||
677 | /// Refreshs prompt with the current selection details. | ||
678 | /// </summary> | ||
679 | private void RefreshPrompt() | ||
680 | { | ||
673 | string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); | 681 | string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); |
674 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); | 682 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); |
675 | 683 | ||
@@ -691,6 +699,18 @@ namespace OpenSim | |||
691 | m_console.ConsoleScene = SceneManager.CurrentScene; | 699 | m_console.ConsoleScene = SceneManager.CurrentScene; |
692 | } | 700 | } |
693 | 701 | ||
702 | protected override void HandleRestartRegion(RegionInfo whichRegion) | ||
703 | { | ||
704 | base.HandleRestartRegion(whichRegion); | ||
705 | |||
706 | // Where we are restarting multiple scenes at once, a previous call to RefreshPrompt may have set the | ||
707 | // m_console.ConsoleScene to null (indicating all scenes). | ||
708 | if (m_console.ConsoleScene != null && whichRegion.RegionName == ((Scene)m_console.ConsoleScene).Name) | ||
709 | SceneManager.TrySetCurrentScene(whichRegion.RegionName); | ||
710 | |||
711 | RefreshPrompt(); | ||
712 | } | ||
713 | |||
694 | /// <summary> | 714 | /// <summary> |
695 | /// Turn on some debugging values for OpenSim. | 715 | /// Turn on some debugging values for OpenSim. |
696 | /// </summary> | 716 | /// </summary> |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index b40aa4b..c3c87e7 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -299,7 +299,7 @@ namespace OpenSim | |||
299 | // Called from base.StartUp() | 299 | // Called from base.StartUp() |
300 | 300 | ||
301 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | 301 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; |
302 | SceneManager.OnRestartSim += handleRestartRegion; | 302 | SceneManager.OnRestartSim += HandleRestartRegion; |
303 | 303 | ||
304 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is | 304 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is |
305 | // heavily used during initial startup. | 305 | // heavily used during initial startup. |
@@ -735,9 +735,11 @@ namespace OpenSim | |||
735 | } | 735 | } |
736 | } | 736 | } |
737 | 737 | ||
738 | public void handleRestartRegion(RegionInfo whichRegion) | 738 | protected virtual void HandleRestartRegion(RegionInfo whichRegion) |
739 | { | 739 | { |
740 | m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); | 740 | m_log.InfoFormat( |
741 | "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", | ||
742 | whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); | ||
741 | 743 | ||
742 | ShutdownClientServer(whichRegion); | 744 | ShutdownClientServer(whichRegion); |
743 | IScene scene; | 745 | IScene scene; |
@@ -883,7 +885,6 @@ namespace OpenSim | |||
883 | m_log.Info("[SHUTDOWN]: Closing all threads"); | 885 | m_log.Info("[SHUTDOWN]: Closing all threads"); |
884 | m_log.Info("[SHUTDOWN]: Killing listener thread"); | 886 | m_log.Info("[SHUTDOWN]: Killing listener thread"); |
885 | m_log.Info("[SHUTDOWN]: Killing clients"); | 887 | m_log.Info("[SHUTDOWN]: Killing clients"); |
886 | // TODO: implement this | ||
887 | m_log.Info("[SHUTDOWN]: Closing console and terminating"); | 888 | m_log.Info("[SHUTDOWN]: Closing console and terminating"); |
888 | 889 | ||
889 | try | 890 | try |
@@ -892,7 +893,7 @@ namespace OpenSim | |||
892 | } | 893 | } |
893 | catch (Exception e) | 894 | catch (Exception e) |
894 | { | 895 | { |
895 | m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e); | 896 | m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e); |
896 | } | 897 | } |
897 | } | 898 | } |
898 | 899 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index db45d6b..8ef22bd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1134,15 +1134,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1134 | } | 1134 | } |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | m_log.Error("[REGION]: Closing"); | 1137 | m_log.InfoFormat("[REGION]: Restarting region {0}", Name); |
1138 | Close(); | ||
1139 | 1138 | ||
1140 | if (PhysicsScene != null) | 1139 | Close(); |
1141 | { | ||
1142 | PhysicsScene.Dispose(); | ||
1143 | } | ||
1144 | |||
1145 | m_log.Error("[REGION]: Firing Region Restart Message"); | ||
1146 | 1140 | ||
1147 | base.Restart(); | 1141 | base.Restart(); |
1148 | } | 1142 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 1c236db..1e2e973 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -100,23 +100,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly List<Scene> m_localScenes = new List<Scene>(); |
103 | private Scene m_currentScene = null; | ||
104 | 103 | ||
105 | public List<Scene> Scenes | 104 | public List<Scene> Scenes |
106 | { | 105 | { |
107 | get { return new List<Scene>(m_localScenes); } | 106 | get { return new List<Scene>(m_localScenes); } |
108 | } | 107 | } |
109 | 108 | ||
110 | public Scene CurrentScene | 109 | /// <summary> |
111 | { | 110 | /// Scene selected from the console. |
112 | get { return m_currentScene; } | 111 | /// </summary> |
113 | } | 112 | /// <value> |
113 | /// If null, then all scenes are considered selected (signalled as "Root" on the console). | ||
114 | /// </value> | ||
115 | public Scene CurrentScene { get; private set; } | ||
114 | 116 | ||
115 | public Scene CurrentOrFirstScene | 117 | public Scene CurrentOrFirstScene |
116 | { | 118 | { |
117 | get | 119 | get |
118 | { | 120 | { |
119 | if (m_currentScene == null) | 121 | if (CurrentScene == null) |
120 | { | 122 | { |
121 | lock (m_localScenes) | 123 | lock (m_localScenes) |
122 | { | 124 | { |
@@ -128,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | } | 130 | } |
129 | else | 131 | else |
130 | { | 132 | { |
131 | return m_currentScene; | 133 | return CurrentScene; |
132 | } | 134 | } |
133 | } | 135 | } |
134 | } | 136 | } |
@@ -178,8 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
178 | 180 | ||
179 | public void HandleRestart(RegionInfo rdata) | 181 | public void HandleRestart(RegionInfo rdata) |
180 | { | 182 | { |
181 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 183 | Scene restartedScene = null; |
182 | int RegionSceneElement = -1; | ||
183 | 184 | ||
184 | lock (m_localScenes) | 185 | lock (m_localScenes) |
185 | { | 186 | { |
@@ -187,19 +188,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | { | 188 | { |
188 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | 189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) |
189 | { | 190 | { |
190 | RegionSceneElement = i; | 191 | restartedScene = m_localScenes[i]; |
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
191 | } | 194 | } |
192 | } | 195 | } |
193 | |||
194 | // Now we make sure the region is no longer known about by the SceneManager | ||
195 | // Prevents duplicates. | ||
196 | |||
197 | if (RegionSceneElement >= 0) | ||
198 | { | ||
199 | m_localScenes.RemoveAt(RegionSceneElement); | ||
200 | } | ||
201 | } | 196 | } |
202 | 197 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | ||
199 | // hasn't yet been recreated. We will have to leave this to the caller. | ||
200 | if (CurrentScene == restartedScene) | ||
201 | CurrentScene = null; | ||
202 | |||
203 | // Send signal to main that we're restarting this sim. | 203 | // Send signal to main that we're restarting this sim. |
204 | OnRestartSim(rdata); | 204 | OnRestartSim(rdata); |
205 | } | 205 | } |
@@ -341,14 +341,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
341 | 341 | ||
342 | private void ForEachCurrentScene(Action<Scene> func) | 342 | private void ForEachCurrentScene(Action<Scene> func) |
343 | { | 343 | { |
344 | if (m_currentScene == null) | 344 | if (CurrentScene == null) |
345 | { | 345 | { |
346 | lock (m_localScenes) | 346 | lock (m_localScenes) |
347 | m_localScenes.ForEach(func); | 347 | m_localScenes.ForEach(func); |
348 | } | 348 | } |
349 | else | 349 | else |
350 | { | 350 | { |
351 | func(m_currentScene); | 351 | func(CurrentScene); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
@@ -368,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | || (String.Compare(regionName, "..") == 0) | 368 | || (String.Compare(regionName, "..") == 0) |
369 | || (String.Compare(regionName, "/") == 0)) | 369 | || (String.Compare(regionName, "/") == 0)) |
370 | { | 370 | { |
371 | m_currentScene = null; | 371 | CurrentScene = null; |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | else | 374 | else |
@@ -379,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
379 | { | 379 | { |
380 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | 380 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) |
381 | { | 381 | { |
382 | m_currentScene = scene; | 382 | CurrentScene = scene; |
383 | return true; | 383 | return true; |
384 | } | 384 | } |
385 | } | 385 | } |
@@ -399,7 +399,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | { | 399 | { |
400 | if (scene.RegionInfo.RegionID == regionID) | 400 | if (scene.RegionInfo.RegionID == regionID) |
401 | { | 401 | { |
402 | m_currentScene = scene; | 402 | CurrentScene = scene; |
403 | return true; | 403 | return true; |
404 | } | 404 | } |
405 | } | 405 | } |