aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
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
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 '')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs46
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs14
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs19
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs8
-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
8 files changed, 287 insertions, 5 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index ed16cd4..8edfc6f 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -320,7 +320,7 @@ namespace OpenSim
320 plugin.Initialise(this); 320 plugin.Initialise(this);
321 m_plugins.Add(plugin); 321 m_plugins.Add(plugin);
322 } 322 }
323 323
324 // Start UDP servers 324 // Start UDP servers
325 for (int i = 0; i < m_udpServers.Count; i++) 325 for (int i = 0; i < m_udpServers.Count; i++)
326 { 326 {
@@ -412,6 +412,50 @@ namespace OpenSim
412 412
413 m_assetCache = new AssetCache(assetServer, m_log); 413 m_assetCache = new AssetCache(assetServer, m_log);
414 // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); 414 // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
415 m_sceneManager.OnReStartSim += handleReStartRegion;
416
417 }
418 public void handleReStartRegion(RegionInfo whichRegion)
419 {
420 MainLog.Instance.Error("MAIN", "Got Restart Singlal from SceneManager");
421 // Shutting down the UDP server
422 bool foundUDPServer = false;
423 int UDPServerElement = 0;
424
425 for (int i = 0; i < m_udpServers.Count; i++)
426 {
427
428 if (m_udpServers[i].RegionHandle == whichRegion.RegionHandle)
429 {
430 UDPServerElement = i;
431 foundUDPServer = true;
432 break;
433 }
434 }
435 if (foundUDPServer)
436 {
437 // m_udpServers[UDPServerElement].Server.End
438 m_udpServers[UDPServerElement].Server.Close();
439 m_udpServers.RemoveAt(UDPServerElement);
440 }
441
442 //Removing the region from the sim's database of regions..
443 int RegionHandleElement = -1;
444 for (int i = 0; i < m_regionData.Count; i++)
445 {
446 if (whichRegion.RegionHandle == m_regionData[i].RegionHandle)
447 {
448 RegionHandleElement = i;
449 }
450 }
451 if (RegionHandleElement >= 0)
452 {
453 m_regionData.RemoveAt(RegionHandleElement);
454 }
455 UDPServer restartingRegion = CreateRegion(whichRegion);
456 restartingRegion.ServerListener();
457 m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle);
458
415 } 459 }
416 460
417 protected override LogBase CreateLog() 461 protected override LogBase CreateLog()
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 8314fc3..8f377c1 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.ClientStack
47 protected EndPoint epSender; 47 protected EndPoint epSender;
48 protected AsyncCallback ReceivedData; 48 protected AsyncCallback ReceivedData;
49 protected PacketServer m_packetServer; 49 protected PacketServer m_packetServer;
50 protected ulong m_regionHandle;
50 51
51 protected int listenPort; 52 protected int listenPort;
52 protected IScene m_localScene; 53 protected IScene m_localScene;
@@ -66,6 +67,15 @@ namespace OpenSim.Region.ClientStack
66 { 67 {
67 m_localScene = value; 68 m_localScene = value;
68 m_packetServer.LocalScene = m_localScene; 69 m_packetServer.LocalScene = m_localScene;
70 m_regionHandle = m_localScene.RegionInfo.RegionHandle;
71 }
72
73 }
74 public ulong RegionHandle
75 {
76 get
77 {
78 return m_regionHandle;
69 } 79 }
70 } 80 }
71 81
@@ -115,6 +125,10 @@ namespace OpenSim.Region.ClientStack
115 125
116 return; 126 return;
117 } 127 }
128 catch (System.ObjectDisposedException od)
129 {
130 return;
131 }
118 132
119 int packetEnd = numBytes - 1; 133 int packetEnd = numBytes - 1;
120 134
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
index c569fc5..b847e4f 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -171,6 +171,12 @@ namespace OpenSim.Region.Environment
171 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId)) 171 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
172 estateSetRegionTerrainHandler(packet); 172 estateSetRegionTerrainHandler(packet);
173 break; 173 break;
174 case "restart":
175 if (m_scene.PermissionsMngr.CanRestartSim(remote_client.AgentId))
176 {
177 estateRestartSim(packet);
178 }
179 break;
174 default: 180 default:
175 MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString()); 181 MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
176 break; 182 break;
@@ -322,6 +328,19 @@ namespace OpenSim.Region.Environment
322 } 328 }
323 } 329 }
324 } 330 }
331 private void estateRestartSim(EstateOwnerMessagePacket packet)
332 {
333 // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
334 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
335 {
336 float timeSeconds = 0;
337 timeSeconds = BitConverter.ToInt16(block.Parameter, 1);
338 timeSeconds = (int)((timeSeconds / 100) - 3);
339 m_scene.Restart(timeSeconds);
340
341 }
342 }
343
325 344
326 #endregion 345 #endregion
327 346
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index 412c6e7..6efa116 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -306,6 +306,14 @@ namespace OpenSim.Region.Environment
306 return GenericEstatePermission(user); 306 return GenericEstatePermission(user);
307 } 307 }
308 308
309 public virtual bool CanRestartSim(LLUUID user)
310 {
311 // Since this is potentially going on a grid...
312
313 //return GenericEstatePermission(AgentId);
314 return m_scene.RegionInfo.MasterAvatarAssignedUUID == user;
315 }
316
309 #endregion 317 #endregion
310 318
311 #region Parcel Permissions 319 #region Parcel Permissions
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);