diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 124 |
1 files changed, 69 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 44a738e..34ad58a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -215,14 +215,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
215 | /// </summary> | 215 | /// </summary> |
216 | private bool m_cleaningTemps = false; | 216 | private bool m_cleaningTemps = false; |
217 | 217 | ||
218 | private Object m_heartbeatLock = new Object(); | 218 | // private Object m_heartbeatLock = new Object(); |
219 | 219 | ||
220 | // TODO: Possibly stop other classes being able to manipulate this directly. | 220 | // TODO: Possibly stop other classes being able to manipulate this directly. |
221 | private SceneGraph m_sceneGraph; | 221 | private SceneGraph m_sceneGraph; |
222 | private volatile int m_bordersLocked; | 222 | private volatile int m_bordersLocked; |
223 | // private int m_RestartTimerCounter; | ||
224 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 223 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
225 | // private int m_incrementsof15seconds; | ||
226 | private volatile bool m_backingup; | 224 | private volatile bool m_backingup; |
227 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 225 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
228 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 226 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); |
@@ -230,16 +228,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
230 | private bool m_physics_enabled = true; | 228 | private bool m_physics_enabled = true; |
231 | private bool m_scripts_enabled = true; | 229 | private bool m_scripts_enabled = true; |
232 | private string m_defaultScriptEngine; | 230 | private string m_defaultScriptEngine; |
231 | |||
232 | /// <summary> | ||
233 | /// Tick at which the last login occurred. | ||
234 | /// </summary> | ||
233 | private int m_LastLogin; | 235 | private int m_LastLogin; |
234 | private Thread HeartbeatThread = null; | ||
235 | private volatile bool shuttingdown; | ||
236 | 236 | ||
237 | private int m_lastUpdate; | ||
238 | private int m_lastIncoming; | 237 | private int m_lastIncoming; |
239 | private int m_lastOutgoing; | 238 | private int m_lastOutgoing; |
240 | private bool m_firstHeartbeat = true; | ||
241 | private int m_hbRestarts = 0; | 239 | private int m_hbRestarts = 0; |
242 | 240 | ||
241 | |||
242 | /// <summary> | ||
243 | /// Thread that runs the scene loop. | ||
244 | /// </summary> | ||
245 | private Thread m_heartbeatThread; | ||
246 | |||
247 | /// <summary> | ||
248 | /// True if these scene is in the process of shutting down or is shutdown. | ||
249 | /// </summary> | ||
250 | public bool ShuttingDown | ||
251 | { | ||
252 | get { return m_shuttingDown; } | ||
253 | } | ||
254 | private volatile bool m_shuttingDown; | ||
255 | |||
256 | // private int m_lastUpdate; | ||
257 | private bool m_firstHeartbeat = true; | ||
258 | |||
243 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 259 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
244 | private bool m_reprioritizationEnabled = true; | 260 | private bool m_reprioritizationEnabled = true; |
245 | private double m_reprioritizationInterval = 5000.0; | 261 | private double m_reprioritizationInterval = 5000.0; |
@@ -577,7 +593,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
577 | m_EstateDataService = estateDataService; | 593 | m_EstateDataService = estateDataService; |
578 | m_regionHandle = m_regInfo.RegionHandle; | 594 | m_regionHandle = m_regInfo.RegionHandle; |
579 | m_regionName = m_regInfo.RegionName; | 595 | m_regionName = m_regInfo.RegionName; |
580 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
581 | m_lastIncoming = 0; | 596 | m_lastIncoming = 0; |
582 | m_lastOutgoing = 0; | 597 | m_lastOutgoing = 0; |
583 | 598 | ||
@@ -834,18 +849,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
834 | 849 | ||
835 | m_permissions = new ScenePermissions(this); | 850 | m_permissions = new ScenePermissions(this); |
836 | 851 | ||
837 | m_lastUpdate = Util.EnvironmentTickCount(); | 852 | // m_lastUpdate = Util.EnvironmentTickCount(); |
838 | } | 853 | } |
839 | 854 | ||
840 | #endregion | 855 | #endregion |
841 | 856 | ||
842 | #region Startup / Close Methods | 857 | #region Startup / Close Methods |
843 | 858 | ||
844 | public bool ShuttingDown | ||
845 | { | ||
846 | get { return shuttingdown; } | ||
847 | } | ||
848 | |||
849 | /// <value> | 859 | /// <value> |
850 | /// The scene graph for this scene | 860 | /// The scene graph for this scene |
851 | /// </value> | 861 | /// </value> |
@@ -1107,6 +1117,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1107 | m_physics_enabled = enablePhysics; | 1117 | m_physics_enabled = enablePhysics; |
1108 | } | 1118 | } |
1109 | 1119 | ||
1120 | // if (options.ContainsKey("collisions")) | ||
1121 | // { | ||
1122 | // // TODO: Implement. If false, should stop objects colliding, though possibly should still allow | ||
1123 | // // the avatar themselves to collide with the ground. | ||
1124 | // } | ||
1125 | |||
1110 | if (options.ContainsKey("teleport")) | 1126 | if (options.ContainsKey("teleport")) |
1111 | { | 1127 | { |
1112 | bool enableTeleportDebugging; | 1128 | bool enableTeleportDebugging; |
@@ -1158,8 +1174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1158 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1174 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1159 | 1175 | ||
1160 | // Stop updating the scene objects and agents. | 1176 | // Stop updating the scene objects and agents. |
1161 | //m_heartbeatTimer.Close(); | 1177 | m_shuttingDown = true; |
1162 | shuttingdown = true; | ||
1163 | 1178 | ||
1164 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1179 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1165 | EventManager.TriggerSceneShuttingDown(this); | 1180 | EventManager.TriggerSceneShuttingDown(this); |
@@ -1183,16 +1198,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | } | 1198 | } |
1184 | 1199 | ||
1185 | /// <summary> | 1200 | /// <summary> |
1186 | /// Start the timer which triggers regular scene updates | 1201 | /// Start the scene |
1187 | /// </summary> | 1202 | /// </summary> |
1188 | public void StartTimer() | 1203 | public void Start() |
1189 | { | 1204 | { |
1190 | // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); | 1205 | // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); |
1191 | 1206 | ||
1192 | //m_heartbeatTimer.Enabled = true; | 1207 | //m_heartbeatTimer.Enabled = true; |
1193 | //m_heartbeatTimer.Interval = (int)(m_timespan * 1000); | 1208 | //m_heartbeatTimer.Interval = (int)(m_timespan * 1000); |
1194 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1209 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1195 | if (HeartbeatThread != null) | 1210 | if (m_heartbeatThread != null) |
1196 | { | 1211 | { |
1197 | m_hbRestarts++; | 1212 | m_hbRestarts++; |
1198 | if(m_hbRestarts > 10) | 1213 | if(m_hbRestarts > 10) |
@@ -1208,13 +1223,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1208 | //proc.WaitForExit(); | 1223 | //proc.WaitForExit(); |
1209 | //Thread.Sleep(1000); | 1224 | //Thread.Sleep(1000); |
1210 | //Environment.Exit(1); | 1225 | //Environment.Exit(1); |
1211 | HeartbeatThread.Abort(); | 1226 | m_heartbeatThread.Abort(); |
1212 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | 1227 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); |
1213 | HeartbeatThread = null; | 1228 | m_heartbeatThread = null; |
1214 | } | 1229 | } |
1215 | m_lastUpdate = Util.EnvironmentTickCount(); | 1230 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1216 | 1231 | ||
1217 | HeartbeatThread | 1232 | m_heartbeatThread |
1218 | = Watchdog.StartThread( | 1233 | = Watchdog.StartThread( |
1219 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1234 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
1220 | } | 1235 | } |
@@ -1245,30 +1260,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1245 | /// </summary> | 1260 | /// </summary> |
1246 | private void Heartbeat() | 1261 | private void Heartbeat() |
1247 | { | 1262 | { |
1248 | if (!Monitor.TryEnter(m_heartbeatLock)) | 1263 | // if (!Monitor.TryEnter(m_heartbeatLock)) |
1249 | { | 1264 | // { |
1250 | Watchdog.RemoveThread(); | 1265 | // Watchdog.RemoveThread(); |
1251 | return; | 1266 | // return; |
1252 | } | 1267 | // } |
1253 | 1268 | ||
1254 | try | 1269 | // try |
1255 | { | 1270 | // { |
1256 | m_eventManager.TriggerOnRegionStarted(this); | ||
1257 | 1271 | ||
1258 | // The first frame can take a very long time due to physics actors being added on startup. Therefore, | 1272 | m_eventManager.TriggerOnRegionStarted(this); |
1259 | // don't turn on the watchdog alarm for this thread until the second frame, in order to prevent false | ||
1260 | // alarms for scenes with many objects. | ||
1261 | Update(1); | ||
1262 | Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; | ||
1263 | 1273 | ||
1264 | while (!shuttingdown) | 1274 | // The first frame can take a very long time due to physics actors being added on startup. Therefore, |
1265 | Update(-1); | 1275 | // don't turn on the watchdog alarm for this thread until the second frame, in order to prevent false |
1266 | } | 1276 | // alarms for scenes with many objects. |
1267 | finally | 1277 | Update(1); |
1268 | { | 1278 | Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; |
1269 | Monitor.Pulse(m_heartbeatLock); | 1279 | Update(-1); |
1270 | Monitor.Exit(m_heartbeatLock); | 1280 | |
1271 | } | 1281 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1282 | // m_firstHeartbeat = false; | ||
1283 | // } | ||
1284 | // finally | ||
1285 | // { | ||
1286 | // Monitor.Pulse(m_heartbeatLock); | ||
1287 | // Monitor.Exit(m_heartbeatLock); | ||
1288 | // } | ||
1272 | 1289 | ||
1273 | Watchdog.RemoveThread(); | 1290 | Watchdog.RemoveThread(); |
1274 | } | 1291 | } |
@@ -1287,7 +1304,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1287 | List<Vector3> coarseLocations; | 1304 | List<Vector3> coarseLocations; |
1288 | List<UUID> avatarUUIDs; | 1305 | List<UUID> avatarUUIDs; |
1289 | 1306 | ||
1290 | while (!shuttingdown && (endFrame == null || Frame < endFrame)) | 1307 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) |
1291 | { | 1308 | { |
1292 | maintc = Util.EnvironmentTickCount(); | 1309 | maintc = Util.EnvironmentTickCount(); |
1293 | ++Frame; | 1310 | ++Frame; |
@@ -1463,15 +1480,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1463 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1480 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1464 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1481 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1465 | 1482 | ||
1466 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1467 | m_firstHeartbeat = false; | 1483 | m_firstHeartbeat = false; |
1468 | 1484 | ||
1469 | if (maintc > 0) | 1485 | if (maintc > 0) |
1470 | Thread.Sleep(maintc); | 1486 | Thread.Sleep(maintc); |
1471 | 1487 | ||
1472 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1473 | m_firstHeartbeat = false; | ||
1474 | |||
1475 | // Optionally warn if a frame takes double the amount of time that it should. | 1488 | // Optionally warn if a frame takes double the amount of time that it should. |
1476 | if (DebugUpdates | 1489 | if (DebugUpdates |
1477 | && Util.EnvironmentTickCountSubtract( | 1490 | && Util.EnvironmentTickCountSubtract( |
@@ -2662,7 +2675,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2662 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2675 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2663 | 2676 | ||
2664 | CheckHeartbeat(); | 2677 | CheckHeartbeat(); |
2665 | ScenePresence presence; | ||
2666 | 2678 | ||
2667 | ScenePresence sp = GetScenePresence(client.AgentId); | 2679 | ScenePresence sp = GetScenePresence(client.AgentId); |
2668 | 2680 | ||
@@ -3253,7 +3265,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3253 | 3265 | ||
3254 | public override void RemoveClient(UUID agentID, bool closeChildAgents) | 3266 | public override void RemoveClient(UUID agentID, bool closeChildAgents) |
3255 | { | 3267 | { |
3256 | CheckHeartbeat(); | 3268 | // CheckHeartbeat(); |
3257 | bool isChildAgent = false; | 3269 | bool isChildAgent = false; |
3258 | ScenePresence avatar = GetScenePresence(agentID); | 3270 | ScenePresence avatar = GetScenePresence(agentID); |
3259 | if (avatar != null) | 3271 | if (avatar != null) |
@@ -4700,7 +4712,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4700 | 4712 | ||
4701 | int health=1; // Start at 1, means we're up | 4713 | int health=1; // Start at 1, means we're up |
4702 | 4714 | ||
4703 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) | 4715 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4704 | { | 4716 | { |
4705 | health+=1; | 4717 | health+=1; |
4706 | flags |= 1; | 4718 | flags |= 1; |
@@ -4737,6 +4749,8 @@ Environment.Exit(1); | |||
4737 | // | 4749 | // |
4738 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) | 4750 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4739 | health++; | 4751 | health++; |
4752 | else | ||
4753 | return health; | ||
4740 | 4754 | ||
4741 | return health; | 4755 | return health; |
4742 | } | 4756 | } |
@@ -4929,8 +4943,8 @@ Environment.Exit(1); | |||
4929 | if (m_firstHeartbeat) | 4943 | if (m_firstHeartbeat) |
4930 | return; | 4944 | return; |
4931 | 4945 | ||
4932 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) | 4946 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4933 | StartTimer(); | 4947 | Start(); |
4934 | } | 4948 | } |
4935 | 4949 | ||
4936 | public override ISceneObject DeserializeObject(string representation) | 4950 | public override ISceneObject DeserializeObject(string representation) |