From c605509da3a690d4050c48418111d7f29f7be9b4 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 9 Sep 2009 16:20:19 -0400 Subject: * Lock timers when Calling Start() and Stop() when the Thread Context is murky. This affects Mono only. --- .../RemoteController/RemoteAdminPlugin.cs | 5 +- .../Rest/Inventory/RestInventoryServices.cs | 7 +- OpenSim/Client/MXP/MXPModule.cs | 11 +++- .../InterMessageUserServerModule.cs | 3 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 76 ++++++++++++++++------ .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 5 +- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 6 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 + 8 files changed, 85 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 67ba016..7e0a4ba 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -384,7 +384,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing shutdownTimer.AutoReset = false; shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); - shutdownTimer.Start(); + lock (shutdownTimer) + { + shutdownTimer.Start(); + } responseData["success"] = true; } diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 59431bb..4e03e67 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -2177,13 +2177,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory watchDog.Interval = interval; watchDog.AutoReset = false; watchDog.Enabled = true; - watchDog.Start(); + lock (watchDog) + watchDog.Start(); + } internal void stopWD() { Rest.Log.DebugFormat("{0} Reset watchdog", MsgId); - watchDog.Stop(); + lock (watchDog) + watchDog.Stop(); } /// diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs index dbe4174..2d28b8c 100644 --- a/OpenSim/Client/MXP/MXPModule.cs +++ b/OpenSim/Client/MXP/MXPModule.cs @@ -81,7 +81,8 @@ namespace OpenSim.Client.MXP m_ticker.AutoReset = false; m_ticker.Elapsed += ticker_Elapsed; - m_ticker.Start(); + lock (m_ticker) + m_ticker.Start(); m_log.Info("[MXP ClientStack] MXP Enabled and Listening"); } @@ -99,13 +100,17 @@ namespace OpenSim.Client.MXP } if (!m_shutdown) - m_ticker.Start(); + { + lock (m_ticker) + m_ticker.Start(); + } } public void Close() { m_shutdown = true; - m_ticker.Stop(); + lock (m_ticker) + m_ticker.Stop(); } public string Name diff --git a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs b/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs index 0eb7b6a..ae04535 100644 --- a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs +++ b/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs @@ -58,7 +58,8 @@ namespace OpenSim.Grid.MessagingServer.Modules m_messageCore = messageCore; reconnectTimer.Elapsed += registerWithUserServer; - reconnectTimer.Start(); + lock (reconnectTimer) + reconnectTimer.Start(); } public void Initialise() diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index dd01780..dd50073 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -581,6 +581,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void CloseCleanup(bool shutdownCircuit) { + + m_scene.RemoveClient(AgentId); //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); @@ -592,12 +594,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP Thread.Sleep(2000); - // Shut down timers - if (m_clientPingTimer.Enabled) m_clientPingTimer.Stop(); - if (m_avatarTerseUpdateTimer.Enabled) m_avatarTerseUpdateTimer.Stop(); - if (m_primTerseUpdateTimer.Enabled) m_primTerseUpdateTimer.Stop(); - if (m_primFullUpdateTimer.Enabled) m_primFullUpdateTimer.Stop(); - if (m_textureRequestTimer.Enabled) m_textureRequestTimer.Stop(); + // Shut down timers. Thread Context of this method is murky. Lock all timers + if (m_clientPingTimer.Enabled) + lock (m_clientPingTimer) + m_clientPingTimer.Stop(); + if (m_avatarTerseUpdateTimer.Enabled) + lock (m_avatarTerseUpdateTimer) + m_avatarTerseUpdateTimer.Stop(); + if (m_primTerseUpdateTimer.Enabled) + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); + if (m_primFullUpdateTimer.Enabled) + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); + if (m_textureRequestTimer.Enabled) + lock (m_textureRequestTimer) + m_textureRequestTimer.Stop(); // This is just to give the client a reasonable chance of // flushing out all it's packets. There should probably @@ -676,12 +688,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void Stop() { - // Shut down timers - if (m_clientPingTimer.Enabled) m_clientPingTimer.Stop(); - if (m_avatarTerseUpdateTimer.Enabled) m_avatarTerseUpdateTimer.Stop(); - if (m_primTerseUpdateTimer.Enabled) m_primTerseUpdateTimer.Stop(); - if (m_primFullUpdateTimer.Enabled) m_primFullUpdateTimer.Stop(); - if (m_textureRequestTimer.Enabled) m_textureRequestTimer.Stop(); + // Shut down timers. Thread Context is Murky, lock all timers! + if (m_clientPingTimer.Enabled) + lock (m_clientPingTimer) + m_clientPingTimer.Stop(); + + if (m_avatarTerseUpdateTimer.Enabled) + lock (m_avatarTerseUpdateTimer) + m_avatarTerseUpdateTimer.Stop(); + + if (m_primTerseUpdateTimer.Enabled) + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); + + if (m_primFullUpdateTimer.Enabled) + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); + + if (m_textureRequestTimer.Enabled) + lock (m_textureRequestTimer) + m_textureRequestTimer.Stop(); } public void Restart() @@ -2907,7 +2933,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else if (m_avatarTerseUpdates.Count == 1) { - m_avatarTerseUpdateTimer.Start(); + lock (m_avatarTerseUpdateTimer) + m_avatarTerseUpdateTimer.Start(); } } } @@ -2957,7 +2984,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(terse, ThrottleOutPacketType.Task); if (m_avatarTerseUpdates.Count == 0) - m_avatarTerseUpdateTimer.Stop(); + { + lock (m_avatarTerseUpdateTimer) + m_avatarTerseUpdateTimer.Stop(); + } } } @@ -3138,7 +3168,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_imageManager.ProcessImageQueue(m_textureSendLimit, m_textureDataLimit)) { - m_textureRequestTimer.Start(); + lock(m_textureRequestTimer) + m_textureRequestTimer.Start(); } } } @@ -3149,7 +3180,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) { - m_primFullUpdateTimer.Stop(); + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); return; } @@ -3196,7 +3228,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) - m_primFullUpdateTimer.Stop(); + lock (m_primFullUpdateTimer) + m_primFullUpdateTimer.Stop(); } } @@ -3234,7 +3267,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_primTerseUpdates.Count == 0) { - m_primTerseUpdateTimer.Stop(); + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); return; } @@ -3284,7 +3318,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); if (m_primTerseUpdates.Count == 0) - m_primTerseUpdateTimer.Stop(); + lock (m_primTerseUpdateTimer) + m_primTerseUpdateTimer.Stop(); } } @@ -6586,7 +6621,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_imageManager != null) { m_imageManager.EnqueueReq(args); - m_textureRequestTimer.Start(); + lock (m_textureRequestTimer) + m_textureRequestTimer.Start(); } } } diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 53b8ebc..49b459a 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -160,7 +160,10 @@ namespace Flotsam.RegionModules.AssetCache m_CachCleanTimer.AutoReset = true; m_CachCleanTimer.Elapsed += CleanupExpiredFiles; m_CachCleanTimer.Enabled = true; - m_CachCleanTimer.Start(); + lock (m_CachCleanTimer) + { + m_CachCleanTimer.Start(); + } } else { diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index f8208ec..7ac1e7e 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -78,7 +78,8 @@ namespace OpenSim.Region.Framework.Scenes bool permissionToDelete) { if (Enabled) - m_inventoryTicker.Stop(); + lock (m_inventoryTicker) + m_inventoryTicker.Stop(); lock (m_inventoryDeletes) { @@ -93,7 +94,8 @@ namespace OpenSim.Region.Framework.Scenes } if (Enabled) - m_inventoryTicker.Start(); + lock (m_inventoryTicker) + m_inventoryTicker.Start(); // Visually remove it, even if it isnt really gone yet. This means that if we crash before the object // has gone to inventory, it will reappear in the region again on restart instead of being lost. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 40e7471..b0d279c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3762,6 +3762,8 @@ if (m_shape != null) { lPos = AbsolutePosition; } + // Causes this thread to dig into the Client Thread Data. + // Remember your locking here! remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, -- cgit v1.1