aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-25 04:52:14 +0000
committerTeravus Ovares2007-11-25 04:52:14 +0000
commitd263a044b1ebb13477b2b391637ccc2da4368838 (patch)
tree6288ef8e8f2a1c073705b23db8aba8603a28c34d /OpenSim/Region/Environment/Scenes
parentIgnore nullreferenceexception in removeclient. The avatar is already gone. (diff)
downloadopensim-SC_OLD-d263a044b1ebb13477b2b391637ccc2da4368838.zip
opensim-SC_OLD-d263a044b1ebb13477b2b391637ccc2da4368838.tar.gz
opensim-SC_OLD-d263a044b1ebb13477b2b391637ccc2da4368838.tar.bz2
opensim-SC_OLD-d263a044b1ebb13477b2b391637ccc2da4368838.tar.xz
* Added the ability to restart your individual sims from within them using the estate tools.
* The sims properly restart, however they don't yet notify the existing avatars that they are up. To see the sim again, you'll need to log-out and back in until I can figure out how to get the proper data to the sims and to the avatar so they reconnect again.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs101
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs34
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs14
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs56
4 files changed, 201 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 735dddb..9cdb49b 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -70,6 +70,10 @@ namespace OpenSim.Region.Environment.Scenes
70 private readonly Mutex updateLock; 70 private readonly Mutex updateLock;
71 public bool m_physicalPrim; 71 public bool m_physicalPrim;
72 public bool m_sendTasksToChild; 72 public bool m_sendTasksToChild;
73 private int m_RestartTimerCounter;
74 private Timer t_restartTimer = new Timer(15000); // Wait before firing
75 private int m_incrementsof15seconds = 0;
76
73 protected ModuleLoader m_moduleLoader; 77 protected ModuleLoader m_moduleLoader;
74 protected StorageManager m_storageManager; 78 protected StorageManager m_storageManager;
75 protected AgentCircuitManager m_authenticateHandler; 79 protected AgentCircuitManager m_authenticateHandler;
@@ -253,15 +257,80 @@ namespace OpenSim.Region.Environment.Scenes
253 m_eventManager.OnPermissionError += SendPermissionAlert; 257 m_eventManager.OnPermissionError += SendPermissionAlert;
254 } 258 }
255 259
260 public override void OtherRegionUp(RegionInfo otherRegion)
261 {
262 // Another region is up. We have to tell all our ScenePresences about it
263 // This fails to get the desired effect and needs further work.
264
265 ForEachScenePresence(delegate(ScenePresence agent)
266 {
267 if (!(agent.IsChildAgent))
268 {
269 InformClientOfNeighbor(agent, otherRegion);
270 this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
271
272 }
273 }
274 );
275 }
276 public virtual void Restart(float seconds)
277 {
278 if (seconds < 100)
279 {
280 t_restartTimer.Stop();
281 SendGeneralAlert("Restart Aborted");
282 }
283 else
284 {
285 t_restartTimer.Interval = 15000;
286 m_incrementsof15seconds = (int) seconds/15;
287 m_RestartTimerCounter = 0;
288 t_restartTimer.AutoReset = true;
289 t_restartTimer.Elapsed += new ElapsedEventHandler(restartTimer_Elapsed);
290 MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes");
291 t_restartTimer.Start();
292 SendGeneralAlert("Restarting in 2 Minutes");
293 }
294
295
296 }
297 public void restartTimer_Elapsed(object sender, ElapsedEventArgs e)
298 {
299 m_RestartTimerCounter++;
300 if (m_RestartTimerCounter <= m_incrementsof15seconds)
301 {
302 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
303 SendGeneralAlert("Restarting in " + ((8-m_RestartTimerCounter) * 15) + " seconds");
304 }
305 else
306 {
307 t_restartTimer.Stop();
308 MainLog.Instance.Error("REGION", "Closing");
309 Close();
310 MainLog.Instance.Error("REGION", "Firing Region Restart Message");
311 base.Restart(0);
312 }
313
314 }
256 public override void Close() 315 public override void Close()
257 { 316 {
258 ForEachScenePresence(delegate(ScenePresence avatar) 317 ForEachScenePresence(delegate(ScenePresence avatar)
259 { 318 {
260 avatar.ControllingClient.Kick("The region is going down."); 319 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
320 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
321
322 if (!avatar.IsChildAgent)
323 avatar.ControllingClient.Kick("The simulator is going down.");
324
325 avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task);
261 326
262 }); 327 });
328
329 Thread.Sleep(500);
330
263 ForEachScenePresence(delegate(ScenePresence avatar) 331 ForEachScenePresence(delegate(ScenePresence avatar)
264 { 332 {
333
265 avatar.ControllingClient.Stop(); 334 avatar.ControllingClient.Stop();
266 335
267 }); 336 });
@@ -269,7 +338,7 @@ namespace OpenSim.Region.Environment.Scenes
269 338
270 m_heartbeatTimer.Close(); 339 m_heartbeatTimer.Close();
271 m_innerScene.Close(); 340 m_innerScene.Close();
272 m_sceneGridService.Close(); 341 UnRegisterReginWithComms();
273 342
274 foreach (IRegionModule module in this.Modules.Values) 343 foreach (IRegionModule module in this.Modules.Values)
275 { 344 {
@@ -992,6 +1061,14 @@ namespace OpenSim.Region.Environment.Scenes
992 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; 1061 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
993 m_sceneGridService.OnCloseAgentConnection += CloseConnection; 1062 m_sceneGridService.OnCloseAgentConnection += CloseConnection;
994 } 1063 }
1064 public void UnRegisterReginWithComms()
1065 {
1066 m_sceneGridService.OnExpectUser -= NewUserConnection;
1067 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
1068 m_sceneGridService.OnCloseAgentConnection -= CloseConnection;
1069
1070 m_sceneGridService.Close();
1071 }
995 1072
996 /// <summary> 1073 /// <summary>
997 /// 1074 ///
@@ -1060,6 +1137,10 @@ namespace OpenSim.Region.Environment.Scenes
1060 { 1137 {
1061 m_sceneGridService.EnableNeighbourChildAgents(presence); 1138 m_sceneGridService.EnableNeighbourChildAgents(presence);
1062 } 1139 }
1140 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
1141 {
1142 m_sceneGridService.InformNeighborChildAgent(presence, region);
1143 }
1063 1144
1064 /// <summary> 1145 /// <summary>
1065 /// 1146 ///
@@ -1258,9 +1339,15 @@ namespace OpenSim.Region.Environment.Scenes
1258 1339
1259 ClientManager.ForEachClient(delegate (IClientAPI controller) 1340 ClientManager.ForEachClient(delegate (IClientAPI controller)
1260 { 1341 {
1261 if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? 1342 ScenePresence p = GetScenePresence(controller.AgentId);
1343 bool childagent = false;
1344 if (!p.Equals(null))
1345 if (p.IsChildAgent)
1346 childagent=true;
1347 if (controller.AgentId != godid && !childagent) // Do we really want to kick the initiator of this madness?
1262 { 1348 {
1263 controller.Kick(Helpers.FieldToUTF8String(reason)); 1349 controller.Kick(Helpers.FieldToUTF8String(reason));
1350
1264 } 1351 }
1265 } 1352 }
1266 ); 1353 );
@@ -1269,7 +1356,13 @@ namespace OpenSim.Region.Environment.Scenes
1269 // Is there another way to make sure *all* clients get this 'inter region' message? 1356 // Is there another way to make sure *all* clients get this 'inter region' message?
1270 ClientManager.ForEachClient(delegate (IClientAPI controller) 1357 ClientManager.ForEachClient(delegate (IClientAPI controller)
1271 { 1358 {
1272 if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? 1359 ScenePresence p = GetScenePresence(controller.AgentId);
1360 bool childagent = false;
1361 if (!p.Equals(null))
1362 if (p.IsChildAgent)
1363 childagent = true;
1364
1365 if (controller.AgentId != godid && !childagent) // Do we really want to kick the initiator of this madness?
1273 { 1366 {
1274 controller.Close(); 1367 controller.Close();
1275 } 1368 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 1bb7d10..4359374 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Timers;
30using libsecondlife; 31using libsecondlife;
31using OpenSim.Framework; 32using OpenSim.Framework;
32using OpenSim.Framework.Communications.Cache; 33using OpenSim.Framework.Communications.Cache;
@@ -37,6 +38,13 @@ namespace OpenSim.Region.Environment.Scenes
37{ 38{
38 public abstract class SceneBase : IScene 39 public abstract class SceneBase : IScene
39 { 40 {
41 #region Events
42
43 public event restart OnRestart;
44 public event regionup OnRegionUp;
45
46 #endregion
47
40 #region Fields 48 #region Fields
41 private readonly ClientManager m_clientManager = new ClientManager(); 49 private readonly ClientManager m_clientManager = new ClientManager();
42 50
@@ -48,6 +56,7 @@ namespace OpenSim.Region.Environment.Scenes
48 protected ulong m_regionHandle; 56 protected ulong m_regionHandle;
49 protected string m_regionName; 57 protected string m_regionName;
50 protected RegionInfo m_regInfo; 58 protected RegionInfo m_regInfo;
59 protected RegionStatus m_regStatus;
51 60
52 public TerrainEngine Terrain; 61 public TerrainEngine Terrain;
53 62
@@ -69,6 +78,12 @@ namespace OpenSim.Region.Environment.Scenes
69 set { m_assetCache = value; } 78 set { m_assetCache = value; }
70 } 79 }
71 80
81 public RegionStatus Region_Status
82 {
83 get { return m_regStatus; }
84 set { m_regStatus = value; }
85 }
86
72 #endregion 87 #endregion
73 88
74 #region Update Methods 89 #region Update Methods
@@ -78,6 +93,8 @@ namespace OpenSim.Region.Environment.Scenes
78 /// </summary> 93 /// </summary>
79 public abstract void Update(); 94 public abstract void Update();
80 95
96
97
81 #endregion 98 #endregion
82 99
83 #region Terrain Methods 100 #region Terrain Methods
@@ -130,6 +147,23 @@ namespace OpenSim.Region.Environment.Scenes
130 get { return m_nextLocalId++; } 147 get { return m_nextLocalId++; }
131 } 148 }
132 149
150 #region admin stuff
151
152 /// <summary>
153 /// Region Restart - Seconds till restart.
154 /// </summary>
155 /// <param name="seconds"></param>
156 public virtual void Restart(int seconds)
157 {
158 MainLog.Instance.Error("REGION", "passing Restart Message up the namespace");
159 OnRestart(RegionInfo);
160 }
161
162
163 public abstract void OtherRegionUp(RegionInfo thisRegion);
164
165
166 #endregion
133 #region Shutdown 167 #region Shutdown
134 168
135 /// <summary> 169 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index ad7ff58..9a10c51 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -149,6 +149,20 @@ namespace OpenSim.Region.Environment.Scenes
149 } 149 }
150 } 150 }
151 } 151 }
152 public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region)
153 {
154 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
155 agent.BaseFolder = LLUUID.Zero;
156 agent.InventoryFolder = LLUUID.Zero;
157 agent.startpos = new LLVector3(128, 128, 70);
158 agent.child = true;
159
160 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
161 d.BeginInvoke(avatar, agent, region.RegionHandle, region.ExternalEndPoint,
162 InformClientOfNeighbourCompleted,
163 d);
164 }
165
152 #endregion 166 #endregion
153 167
154 /// <summary> 168 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index e71d946..4360d97 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -34,8 +34,12 @@ using OpenSim.Framework.Console;
34 34
35namespace OpenSim.Region.Environment.Scenes 35namespace OpenSim.Region.Environment.Scenes
36{ 36{
37 public delegate void ReStartSim(RegionInfo thisregion);
38
37 public class SceneManager 39 public class SceneManager
38 { 40 {
41 public event ReStartSim OnReStartSim;
42
39 private readonly List<Scene> m_localScenes; 43 private readonly List<Scene> m_localScenes;
40 private Scene m_currentScene = null; 44 private Scene m_currentScene = null;
41 45
@@ -72,11 +76,63 @@ namespace OpenSim.Region.Environment.Scenes
72 } 76 }
73 } 77 }
74 78
79 public void Close(Scene cscene)
80 {
81 if (m_localScenes.Contains(cscene))
82 {
83 for (int i = 0; i < m_localScenes.Count; i++)
84 {
85 if (m_localScenes[i].Equals(cscene))
86 {
87
88 m_localScenes[i].Close();
89 }
90 }
91 }
92 }
93
75 public void Add(Scene scene) 94 public void Add(Scene scene)
76 { 95 {
96 scene.OnRestart += handleRestart;
77 m_localScenes.Add(scene); 97 m_localScenes.Add(scene);
98
78 } 99 }
79 100
101 public void handleRestart(RegionInfo rdata)
102 {
103 MainLog.Instance.Error("SCENEMANAGER", "Got Restart message for region:" + rdata.RegionName +" Sending up to main");
104 int RegionSceneElement = -1;
105 for (int i = 0; i < m_localScenes.Count; i++)
106 {
107
108 if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
109 RegionSceneElement = i;
110 }
111
112 // Now we make sure the region is no longer known about by the SceneManager
113 // Prevents Duplicates.
114
115 if (RegionSceneElement >= 0)
116 m_localScenes.RemoveAt(RegionSceneElement);
117
118 // Send signal to main that we're restarting this sim.
119 OnReStartSim(rdata);
120 }
121
122 public void SendSimOnlineNotification(ulong regionHandle)
123 {
124
125 for (int i = 0; i < m_localScenes.Count; i++)
126 {
127 if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle)
128 {
129 // Inform other regions to tell their avatar about me
130 m_localScenes[i].OtherRegionUp(m_localScenes[i].RegionInfo);
131 }
132 }
133
134
135 }
80 public void SaveCurrentSceneToXml(string filename) 136 public void SaveCurrentSceneToXml(string filename)
81 { 137 {
82 CurrentOrFirstScene.SavePrimsToXml(filename); 138 CurrentOrFirstScene.SavePrimsToXml(filename);