From b6476eaac35c37862ae74e6f6a070a80cf51c0c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jul 2012 00:00:26 +0100 Subject: Stop sending the viewer an inventory create message if a known attachment item is updated. This doesn't seem to make any sense and probably stems from a period when this code was directly involved in attaching objects directly from the scene. This message is already being sent by InventoryAccessModule code instead. --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 64ee7e4..fff47e2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -566,11 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments item.InvType = (int)InventoryType.Object; m_scene.InventoryService.UpdateItem(item); - - // this gets called when the agent logs off! - if (sp.ControllingClient != null) - sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } + grp.HasGroupChanged = false; // Prevent it being saved over and over } // else -- cgit v1.1 From 356d5972961cc91593cfcc5c529a8ba81381b8f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jul 2012 00:17:51 +0100 Subject: Restore update of inventory item on derez/logout. This is necessary to update the name if this has been changed whilst attached. Note, this behaviour appears to be at variance with the ll grid as of Tues 17 July 2012, testing with viewer 3.2.1. The item name in inventory does not change either at the point of detach or after a relog. --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index fff47e2..d34a8f6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -566,8 +566,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments item.InvType = (int)InventoryType.Object; m_scene.InventoryService.UpdateItem(item); + + // If the name of the object has been changed whilst attached then we want to update the inventory + // item in the viewer. + if (sp.ControllingClient != null) + sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } - + grp.HasGroupChanged = false; // Prevent it being saved over and over } // else -- cgit v1.1 From c489bc1cd2c81273aaf0e0beb23b3714079ce4be Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 17 Jul 2012 15:00:42 +0200 Subject: Make the scrpt running flag work properly --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 14 ++++++++------ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index d570ef7..5793cc9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -312,11 +312,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); - Running = false; - - if (ShuttingDown) + if (!Running) m_startOnInit = false; + Running = false; + // we get new rez events on sim restart, too // but if there is state, then we fire the change // event @@ -352,12 +352,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public void Init() { - if (!m_startOnInit) + if (ShuttingDown) return; if (m_startedFromSavedState) { - Start(); + if (m_startOnInit) + Start(); if (m_postOnRez) { PostEvent(new EventParams("on_rez", @@ -389,7 +390,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else { - Start(); + if (m_startOnInit) + Start(); PostEvent(new EventParams("state_entry", new Object[0], new DetectParams[0])); if (m_postOnRez) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 01aebb6..7a9c80c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -108,6 +108,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine private bool m_KillTimedOutScripts; private string m_ScriptEnginesPath = null; + private ExpiringCache m_runFlags = new ExpiringCache(); + /// /// Is the entire simulator in the process of shutting down? /// @@ -1196,6 +1198,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (instance != null) instance.Init(); + bool runIt; + if (m_runFlags.TryGetValue(itemID, out runIt)) + { + if (!runIt) + StopScript(itemID); + m_runFlags.Remove(itemID); + } + return true; } @@ -1568,6 +1578,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine IScriptInstance instance = GetInstance(itemID); if (instance != null) instance.Start(); + else + m_runFlags.AddOrUpdate(itemID, true, 240); } public void StopScript(UUID itemID) @@ -1579,6 +1591,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. instance.Stop(1000); } + else + { + m_runFlags.AddOrUpdate(itemID, false, 240); + } } public DetectParams GetDetectParams(UUID itemID, int idx) -- cgit v1.1 From 59a29f5f221a1ffe4e22c63ef9da82270442b213 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jul 2012 22:56:21 +0100 Subject: Revert "refactor: make llGiveInventory() use existing GetInventoryItem() method rather than iterate through TaskInventory itself." This reverts commit 58b13d51a7eddb442e38e6dc6790a9e7cf68bad7. --- .../Shared/Api/Implementation/LSL_Api.cs | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f88338d..c1ac0e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3925,8 +3925,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGiveInventory(string destination, string inventory) { m_host.AddScriptLPS(1); - + bool found = false; UUID destId = UUID.Zero; + UUID objId = UUID.Zero; + int assetType = 0; + string objName = String.Empty; if (!UUID.TryParse(destination, out destId)) { @@ -3934,16 +3937,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); + // move the first object found with this inventory name + lock (m_host.TaskInventory) + { + foreach (KeyValuePair inv in m_host.TaskInventory) + { + if (inv.Value.Name == inventory) + { + found = true; + objId = inv.Key; + assetType = inv.Value.Type; + objName = inv.Value.Name; + break; + } + } + } - if (item == null) + if (!found) { llSay(0, String.Format("Could not find object '{0}'", inventory)); throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); } - UUID objId = item.ItemID; - // check if destination is an object if (World.GetSceneObjectPart(destId) != null) { @@ -3974,23 +3989,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; byte[] bucket = new byte[17]; - bucket[0] = (byte)item.Type; + bucket[0] = (byte)assetType; byte[] objBytes = agentItem.ID.GetBytes(); Array.Copy(objBytes, 0, bucket, 1, 16); GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name + ", an object owned by " + - resolveName(m_host.OwnerID) + ",", destId, + m_host.UUID, m_host.Name+", an object owned by "+ + resolveName(m_host.OwnerID)+",", destId, (byte)InstantMessageDialog.TaskInventoryOffered, - false, item.Name + "\n" + m_host.Name + " is located at " + + false, objName+"\n"+m_host.Name+" is located at "+ World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), agentItem.ID, true, m_host.AbsolutePosition, bucket); - if (m_TransferModule != null) m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); - ScriptSleep(3000); } } -- cgit v1.1 From ecb759c1e5b0ea3e1c81310acf3fe31561d2be3a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jul 2012 23:31:38 +0100 Subject: Fix regression where llGiveInventory() had stopped asking non-owner receivers to accept/decline. This appears to be a regression from back in commit db91044 (Mon Aug 22 2011) where we started to send TaskInventoryOffered msg dialog rather than InventoryOffered dialog. This is probably correct, but failed because the bucket was too large and because we wouldn't have handled the TaskInventoryDeclined option anyway. This patch handles both of these and make llGiveInventoryList() use TaskInventoryOffered as well Fixes http://opensimulator.org/mantis/view.php?id=6089 --- .../Avatar/InstantMessage/MessageTransferModule.cs | 19 ++++--- .../Inventory/Transfer/InventoryTransferModule.cs | 4 +- .../Shared/Api/Implementation/LSL_Api.cs | 58 +++++++++++----------- 3 files changed, 43 insertions(+), 38 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 0dad3c4..596174b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -137,13 +137,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (Scene scene in m_Scenes) { // m_log.DebugFormat( -// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", +// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", // toAgentID.ToString(), scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null && !sp.IsChildAgent) { // Local message -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); // Message sent @@ -155,13 +157,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // try child avatar second foreach (Scene scene in m_Scenes) { -// m_log.DebugFormat( -// "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null) { // Local message -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); + m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); // Message sent @@ -170,10 +174,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } } -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); - SendGridInstantMessageViaXMLRPC(im, result); + m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); - return; + SendGridInstantMessageViaXMLRPC(im, result); } private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 19c774f..f3af59a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -297,7 +297,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer }); } } - else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) + else if ( + im.dialog == (byte)InstantMessageDialog.InventoryDeclined + || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) { // Here, the recipient is local and we can assume that the // inventory is loaded. Courtesy of the above bulk update, diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c1ac0e5..b43e8e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3988,22 +3988,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (agentItem == null) return; - byte[] bucket = new byte[17]; - bucket[0] = (byte)assetType; - byte[] objBytes = agentItem.ID.GetBytes(); - Array.Copy(objBytes, 0, bucket, 1, 16); - - GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name+", an object owned by "+ - resolveName(m_host.OwnerID)+",", destId, - (byte)InstantMessageDialog.TaskInventoryOffered, - false, objName+"\n"+m_host.Name+" is located at "+ - World.RegionInfo.RegionName+" "+ - m_host.AbsolutePosition.ToString(), - agentItem.ID, true, m_host.AbsolutePosition, - bucket); if (m_TransferModule != null) + { + byte[] bucket = new byte[] { (byte)assetType }; + + GridInstantMessage msg = new GridInstantMessage(World, + m_host.UUID, m_host.Name + ", an object owned by " + + resolveName(m_host.OwnerID) + ",", destId, + (byte)InstantMessageDialog.TaskInventoryOffered, + false, objName + "\n" + m_host.Name + " is located at " + + World.RegionInfo.RegionName + " " + + m_host.AbsolutePosition.ToString(), + agentItem.ID, true, m_host.AbsolutePosition, + bucket); + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + } + ScriptSleep(3000); } } @@ -6410,23 +6411,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (folderID == UUID.Zero) return; - byte[] bucket = new byte[17]; - bucket[0] = (byte)AssetType.Folder; - byte[] objBytes = folderID.GetBytes(); - Array.Copy(objBytes, 0, bucket, 1, 16); - - GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name + ", an object owned by " + - resolveName(m_host.OwnerID) + ",", destID, - (byte)InstantMessageDialog.InventoryOffered, - false, category + "\n" + m_host.Name + " is located at " + - World.RegionInfo.RegionName + " " + - m_host.AbsolutePosition.ToString(), - folderID, true, m_host.AbsolutePosition, - bucket); - if (m_TransferModule != null) + { + byte[] bucket = new byte[] { (byte)AssetType.Folder }; + + GridInstantMessage msg = new GridInstantMessage(World, + m_host.UUID, m_host.Name + ", an object owned by " + + resolveName(m_host.OwnerID) + ",", destID, + (byte)InstantMessageDialog.TaskInventoryOffered, + false, category + "\n" + m_host.Name + " is located at " + + World.RegionInfo.RegionName + " " + + m_host.AbsolutePosition.ToString(), + folderID, true, m_host.AbsolutePosition, + bucket); + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + } } public void llSetVehicleType(int type) -- cgit v1.1 From 48a5f10be1a7e487690c1b4e7d220e26c53585c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jul 2012 23:48:09 +0100 Subject: Revert "Revert "refactor: make llGiveInventory() use existing GetInventoryItem() method rather than iterate through TaskInventory itself."" This reverts commit 59a29f5f221a1ffe4e22c63ef9da82270442b213. The original revert was committed by mistake - it turns out this was not the cause of Mantis 6089 Conflicts: OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs --- .../Shared/Api/Implementation/LSL_Api.cs | 33 ++++++---------------- 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b43e8e7..084bd41 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3925,11 +3925,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGiveInventory(string destination, string inventory) { m_host.AddScriptLPS(1); - bool found = false; + UUID destId = UUID.Zero; - UUID objId = UUID.Zero; - int assetType = 0; - string objName = String.Empty; if (!UUID.TryParse(destination, out destId)) { @@ -3937,28 +3934,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - // move the first object found with this inventory name - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == inventory) - { - found = true; - objId = inv.Key; - assetType = inv.Value.Type; - objName = inv.Value.Name; - break; - } - } - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); - if (!found) + if (item == null) { llSay(0, String.Format("Could not find object '{0}'", inventory)); throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); } + UUID objId = item.ItemID; + // check if destination is an object if (World.GetSceneObjectPart(destId) != null) { @@ -3990,14 +3975,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_TransferModule != null) { - byte[] bucket = new byte[] { (byte)assetType }; - + byte[] bucket = new byte[] { (byte)item.Type }; + GridInstantMessage msg = new GridInstantMessage(World, m_host.UUID, m_host.Name + ", an object owned by " + resolveName(m_host.OwnerID) + ",", destId, (byte)InstantMessageDialog.TaskInventoryOffered, - false, objName + "\n" + m_host.Name + " is located at " + - World.RegionInfo.RegionName + " " + + false, item.Name + "\n" + m_host.Name + " is located at " + + World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), agentItem.ID, true, m_host.AbsolutePosition, bucket); -- cgit v1.1 From eb590becf03d94d9afeef471c000c46b044d0c5b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 00:14:02 +0100 Subject: Close() the ScenePresence after we've removed it from the scene graph, to cut down race conditions when another thread manages the grab the presence after some SP structures have been reset. --- OpenSim/Region/Framework/Scenes/Scene.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3e9583c..de2b192 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3317,24 +3317,30 @@ namespace OpenSim.Region.Framework.Scenes if (AgentTransactionsModule != null) AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); - avatar.Close(); - m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); } catch (Exception e) { m_log.Error( - string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e); + string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e); } finally { - // Always clean these structures up so that any failure above doesn't cause them to remain in the - // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering - // the same cleanup exception continually. - // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE - // since this would hide the underlying failure and other associated problems. - m_sceneGraph.RemoveScenePresence(agentID); - m_clientManager.Remove(agentID); + try + { + // Always clean these structures up so that any failure above doesn't cause them to remain in the + // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering + // the same cleanup exception continually. + m_sceneGraph.RemoveScenePresence(agentID); + m_clientManager.Remove(agentID); + + avatar.Close(); + } + catch (Exception e) + { + m_log.Error( + string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e); + } } //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); -- cgit v1.1 From cd6d7429f86eda4040cde664de4d690945d8be6b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 21:03:35 +0100 Subject: Only listen to LoginsEnabled event in RegionReadyModule if it has been asked to disable logins until all scripts have been compiled --- .../RegionReadyModule/RegionReadyModule.cs | 48 ++++++++++------------ 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 600cafb..aeab61c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady private bool m_lastOarLoadedOk; private int m_channelNotify = -1000; private bool m_enabled = false; - private bool m_disable_logins = false; + private bool m_disable_logins; private string m_uri = string.Empty; Scene m_scene = null; @@ -100,24 +100,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; m_scene.EventManager.OnRezScript += OnRezScript; - m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); - if (m_disable_logins == true) + if (m_disable_logins) { + m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; scene.LoginLock = true; - scene.LoginsDisabled = true; - m_log.InfoFormat("[RegionReady]: Region {0} - logins disabled during initialization.",m_scene.RegionInfo.RegionName); + m_log.InfoFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); - if(m_uri != string.Empty) + if (m_uri != string.Empty) { RRAlert("disabled"); } } } - void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { if (!m_ScriptRez) { @@ -132,11 +131,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (!m_enabled) return; - m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; - m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; - if(m_uri != string.Empty) + if (m_disable_logins) + m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; + + if (m_uri != string.Empty) { RRAlert("shutdown"); } @@ -159,7 +159,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady #endregion - void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { m_log.DebugFormat("[RegionReady]: Script compile queue empty!"); @@ -216,27 +215,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady // empty compile queue void OnLoginsEnabled(string regionName) { - if (m_disable_logins == true) + if (m_scene.StartDisabled == false) { - if (m_scene.StartDisabled == false) - { - m_scene.LoginsDisabled = false; - m_scene.LoginLock = false; + m_scene.LoginsDisabled = false; + m_scene.LoginLock = false; - m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", + // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); - // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", - // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); + m_log.InfoFormat( + "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); - m_log.InfoFormat( - "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); - - if (m_uri != string.Empty) - { - RRAlert("enabled"); - } + if (m_uri != string.Empty) + { + RRAlert("enabled"); } } + + m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; } public void OarLoadingAlert(string msg) -- cgit v1.1 From 0dd14ca0a3c78ea4b8d02b1024ac8be8404ae427 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Wed, 18 Jul 2012 13:05:48 -0700 Subject: Missing parameter in log error message was throwing exception --- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 661e03c..305f8a4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", - x / Constants.RegionSize, y / Constants.RegionSize); + m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize); } } -- cgit v1.1 From 6460e587c470361173291337ad222f48c13a10ce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 21:29:12 +0100 Subject: Pass entire scene object in OnLoginsEnabled event rather than just the region name. This saves listeners from having to re-retrieve the scene from their own lists, which won't work anyway if multiple regions with the same name have been allowed --- .../MapImage/MapImageServiceModule.cs | 13 ++---------- OpenSim/Region/Framework/Scenes/EventManager.cs | 7 +++---- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../RegionReadyModule/RegionReadyModule.cs | 24 ++++++++++++++-------- 4 files changed, 22 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 322a9f8..9033460 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -164,20 +164,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage #endregion ISharedRegionModule - void OnLoginsEnabled(string regionName) + void OnLoginsEnabled(IScene scene) { - Scene scene = null; - foreach (Scene s in m_scenes.Values) - if (s.RegionInfo.RegionName == regionName) - { - scene = s; - break; - } - if (scene != null) - UploadMapTile(scene); + UploadMapTile(scene); } - /// /// /// diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index f92ed8e..e2380b7 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -496,14 +496,13 @@ namespace OpenSim.Region.Framework.Scenes public delegate void RegionHeartbeatEnd(Scene scene); public event RegionHeartbeatEnd OnRegionHeartbeatEnd; - public delegate void LoginsEnabled(string regionName); - /// /// This should only fire in all circumstances if the RegionReady module is active. /// /// /// TODO: Fire this even when the RegionReady module is not active. /// + public delegate void LoginsEnabled(IScene scene); public event LoginsEnabled OnLoginsEnabled; public delegate void PrimsLoaded(Scene s); @@ -2477,7 +2476,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerLoginsEnabled (string regionName) + public void TriggerLoginsEnabled(Scene scene) { LoginsEnabled handler = OnLoginsEnabled; @@ -2487,7 +2486,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - d(regionName); + d(scene); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index de2b192..8a28ee4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1493,7 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes { // need to be able to tell these have changed in RegionReady LoginLock = false; - EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); + EventManager.TriggerLoginsEnabled(this); } // For RegionReady lockouts diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index aeab61c..29515de 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady private bool m_disable_logins; private string m_uri = string.Empty; - Scene m_scene = null; + Scene m_scene; #region INonSharedRegionModule interface @@ -192,7 +192,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); m_scene.EventManager.TriggerOnChatBroadcast(this, c); - m_scene.EventManager.TriggerLoginsEnabled(m_scene.RegionInfo.RegionName); + m_scene.EventManager.TriggerLoginsEnabled(m_scene); m_scene.SceneGridService.InformNeighborsThatRegionisUp(m_scene.RequestModuleInterface(), m_scene.RegionInfo); } } @@ -200,20 +200,28 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady void OnOarFileLoaded(Guid requestId, string message) { m_oarFileLoading = true; + if (message==String.Empty) { m_lastOarLoadedOk = true; - } else { + } + else + { m_log.WarnFormat("[RegionReady]: Oar file load errors: {0}", message); m_lastOarLoadedOk = false; } } - // This will be triggerd by Scene if we have no scripts - // m_ScriptsRezzing will be false if there were none - // else it will be true and we should wait on the - // empty compile queue - void OnLoginsEnabled(string regionName) + /// + /// This will be triggered by Scene directly if it contains no scripts on startup. + /// + /// + /// m_ScriptsRezzing will be false if there were none + /// else it will be true and we should wait on the + /// empty compile queue + /// + /// + void OnLoginsEnabled(IScene scene) { if (m_scene.StartDisabled == false) { -- cgit v1.1 From 4973fddc51a4a9e3952bd2decd0ea1842b742141 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 21:52:07 +0100 Subject: Establish EventManager.OnRegionReady event. This will only be triggerred once when the region is ready. Switch MapImageServiceModule to use this. --- .../MapImage/MapImageServiceModule.cs | 10 ++---- OpenSim/Region/Framework/Scenes/EventManager.cs | 37 ++++++++++++++++++++-- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../RegionReadyModule/RegionReadyModule.cs | 2 ++ 4 files changed, 39 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 9033460..5641804 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -146,10 +146,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage lock (m_scenes) m_scenes[scene.RegionInfo.RegionID] = scene; - scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; + scene.EventManager.OnRegionReady += s => UploadMapTile(s); } - /// /// /// @@ -163,12 +162,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } #endregion ISharedRegionModule - - void OnLoginsEnabled(IScene scene) - { - UploadMapTile(scene); - } - + /// /// /// diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index e2380b7..714d70d 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -505,6 +505,16 @@ namespace OpenSim.Region.Framework.Scenes public delegate void LoginsEnabled(IScene scene); public event LoginsEnabled OnLoginsEnabled; + /// + /// Fired when a region is considered ready for use. + /// + /// + /// A region is considered ready when startup operations such as loading of scripts already on the region + /// have been completed. + /// + public delegate void RegionReady(IScene scene); + public event RegionReady OnRegionReady; + public delegate void PrimsLoaded(Scene s); public event PrimsLoaded OnPrimsLoaded; @@ -2476,11 +2486,11 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerLoginsEnabled(Scene scene) + public void TriggerLoginsEnabled(IScene scene) { LoginsEnabled handler = OnLoginsEnabled; - if ( handler != null) + if (handler != null) { foreach (LoginsEnabled d in handler.GetInvocationList()) { @@ -2490,7 +2500,28 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}", + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnLoginsEnabled failed - continuing {0} - {1}", + e.Message, e.StackTrace); + } + } + } + } + + public void TriggerRegionReady(IScene scene) + { + RegionReady handler = OnRegionReady; + + if (handler != null) + { + foreach (RegionReady d in handler.GetInvocationList()) + { + try + { + d(scene); + } + catch (Exception e) + { + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady failed - continuing {0} - {1}", e.Message, e.StackTrace); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8a28ee4..12cc0d3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1501,6 +1501,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); LoginsDisabled = false; + EventManager.TriggerRegionReady(this); } m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 29515de..e09e633 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -238,6 +238,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { RRAlert("enabled"); } + + m_scene.EventManager.TriggerRegionReady(m_scene); } m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; -- cgit v1.1 From 58b72933c814ed393bdf29622d218dd66805af4d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 22:09:20 +0100 Subject: Fix bug where region ready was being triggered twice in quick succession if a region contained no scripts. --- OpenSim/Region/Framework/Scenes/Scene.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 12cc0d3..cadcec0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1488,22 +1488,25 @@ namespace OpenSim.Region.Framework.Scenes IConfig startupConfig = m_config.Configs["Startup"]; if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) { - // This handles a case of a region having no scripts for the RegionReady module - if (m_sceneGraph.GetActiveScriptsCount() == 0) + if (LoginLock) { - // need to be able to tell these have changed in RegionReady - LoginLock = false; - EventManager.TriggerLoginsEnabled(this); + // This handles a case of a region having no scripts for the RegionReady module + if (m_sceneGraph.GetActiveScriptsCount() == 0) + { + // XXX: need to be able to tell these have changed in RegionReady, since it will not + // detect a scenario where the region has no scripts - it's listening to the + // script compile queue. + EventManager.TriggerLoginsEnabled(this); + } } - - // For RegionReady lockouts - if (!LoginLock) + else { m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); LoginsDisabled = false; + EventManager.TriggerLoginsEnabled(this); EventManager.TriggerRegionReady(this); } - + m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); } else -- cgit v1.1 From d97e27434c27b02e1b104abb5577d42452b39452 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 22:17:39 +0100 Subject: Fix bug where region ready would be triggered a second time if a script was rezzed on a previously script-free region. There is no need to listen for OnRezScript in RegionReadyModule since OnEmptyScriptCompileQueue will only fire if scripts were compiled. --- .../RegionReadyModule/RegionReadyModule.cs | 53 ++++++++++------------ 1 file changed, 23 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index e09e633..6b09c3b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -99,14 +99,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_lastOarLoadedOk = true; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; - m_scene.EventManager.OnRezScript += OnRezScript; m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); if (m_disable_logins) { + m_scene.LoginLock = true; m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; - scene.LoginLock = true; + m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; + m_log.InfoFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); if (m_uri != string.Empty) @@ -116,16 +117,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } - void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) - { - if (!m_ScriptRez) - { - m_ScriptRez = true; - m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; - m_scene.EventManager.OnRezScript -= OnRezScript; - } - } - public void RemoveRegion(Scene scene) { if (!m_enabled) @@ -134,7 +125,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; if (m_disable_logins) + { m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; + m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + } if (m_uri != string.Empty) { @@ -249,25 +243,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { // Let's bypass this for now until some better feedback can be established // - return; - if (msg == "load") - { - m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; - m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; - m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; - m_scene.EventManager.OnRezScript += OnRezScript; - m_oarFileLoading = true; - m_firstEmptyCompileQueue = true; - - m_scene.LoginsDisabled = true; - m_scene.LoginLock = true; - if ( m_uri != string.Empty ) - { - RRAlert("loading oar"); - RRAlert("disabled"); - } - } +// if (msg == "load") +// { +// m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; +// m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; +// m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; +// m_scene.EventManager.OnRezScript += OnRezScript; +// m_oarFileLoading = true; +// m_firstEmptyCompileQueue = true; +// +// m_scene.LoginsDisabled = true; +// m_scene.LoginLock = true; +// if ( m_uri != string.Empty ) +// { +// RRAlert("loading oar"); +// RRAlert("disabled"); +// } +// } } public void RRAlert(string status) -- cgit v1.1 From 1971b6bb4f0f15c08dedee95e730ff6485d8c7cf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 22:24:52 +0100 Subject: Stop the 15 second initial script compile wait if a script is being rezzed on a previously empty region. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7a9c80c..da344d6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -644,6 +644,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning; m_Scene.EventManager.OnShutdown += OnShutdown; + // If region ready has been triggered, then the region had no scripts to compile and completed its other + // work. + m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false; + if (m_SleepTime > 0) { m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), -- cgit v1.1 From 528004d34988d8d2349f18ff7d78c6dd50ab8b2d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 23:35:05 +0100 Subject: Perform other region ready actions even if simulator is configured to leave logins disabled on startup. --- .../Framework/Interfaces/IRegionReadyModule.cs | 11 +++++- OpenSim/Region/Framework/Scenes/EventManager.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 37 +++++++++--------- .../RegionReadyModule/RegionReadyModule.cs | 45 +++++++++------------- 4 files changed, 48 insertions(+), 47 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs index aa4a757..136ca92 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs @@ -25,14 +25,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - using System; +using OpenSim.Framework; namespace OpenSim.Region.Framework.Interfaces { public interface IRegionReadyModule { void OarLoadingAlert(string msg); + + /// + /// Trigger region ready status manually. + /// + /// + /// This should be called by the scene if the IRegionReadyModule has set Scene.LoginLock == true + /// + /// + void TriggerRegionReady(IScene scene); } } diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 714d70d..b8ae0ac 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -2506,7 +2506,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - + public void TriggerRegionReady(IScene scene) { RegionReady handler = OnRegionReady; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cadcec0..00aa0ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -702,6 +702,8 @@ namespace OpenSim.Region.Framework.Scenes { IConfig startupConfig = m_config.Configs["Startup"]; + StartDisabled = startupConfig.GetBoolean("StartDisabled", false); + m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); if (!m_useBackup) @@ -1484,35 +1486,32 @@ namespace OpenSim.Region.Framework.Scenes // this is a rare case where we know we have just went through a long cycle of heap // allocations, and there is no more work to be done until someone logs in GC.Collect(); - - IConfig startupConfig = m_config.Configs["Startup"]; - if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) + + if (!LoginLock) { - if (LoginLock) - { - // This handles a case of a region having no scripts for the RegionReady module - if (m_sceneGraph.GetActiveScriptsCount() == 0) - { - // XXX: need to be able to tell these have changed in RegionReady, since it will not - // detect a scenario where the region has no scripts - it's listening to the - // script compile queue. - EventManager.TriggerLoginsEnabled(this); - } - } - else + if (!StartDisabled) { m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); LoginsDisabled = false; EventManager.TriggerLoginsEnabled(this); - EventManager.TriggerRegionReady(this); } - m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); + // Region ready should always be triggered whether logins are immediately enabled or not. + EventManager.TriggerRegionReady(this); } else { - StartDisabled = true; - LoginsDisabled = true; + // This handles a case of a region having no scripts for the RegionReady module + if (m_sceneGraph.GetActiveScriptsCount() == 0) + { + // In this case, we leave it to the IRegionReadyModule to enable logins + + // LoginLock can currently only be set by a region module implementation. + // If somehow this hasn't been done then the quickest way to bugfix is to see the + // NullReferenceException + IRegionReadyModule rrm = RequestModuleInterface(); + rrm.TriggerRegionReady(this); + } } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 6b09c3b..8d5b25f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -31,16 +31,14 @@ using System.Reflection; using System.Net; using System.IO; using System.Text; - using log4net; using Nini.Config; using OpenMetaverse; using OpenMetaverse.StructuredData; -using OpenSim.Services.Interfaces; - using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { @@ -105,7 +103,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (m_disable_logins) { m_scene.LoginLock = true; - m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; m_log.InfoFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); @@ -125,15 +122,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; if (m_disable_logins) - { - m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; - } if (m_uri != string.Empty) - { RRAlert("shutdown"); - } m_scene = null; } @@ -186,8 +178,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); m_scene.EventManager.TriggerOnChatBroadcast(this, c); - m_scene.EventManager.TriggerLoginsEnabled(m_scene); - m_scene.SceneGridService.InformNeighborsThatRegionisUp(m_scene.RequestModuleInterface(), m_scene.RegionInfo); + + TriggerRegionReady(m_scene); } } @@ -207,20 +199,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } /// - /// This will be triggered by Scene directly if it contains no scripts on startup. + /// This will be triggered by Scene directly if it contains no scripts on startup. Otherwise it is triggered + /// when the script compile queue is empty after initial region startup. /// - /// - /// m_ScriptsRezzing will be false if there were none - /// else it will be true and we should wait on the - /// empty compile queue - /// /// - void OnLoginsEnabled(IScene scene) + public void TriggerRegionReady(IScene scene) { - if (m_scene.StartDisabled == false) + m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + m_scene.LoginLock = false; + + if (!m_scene.StartDisabled) { m_scene.LoginsDisabled = false; - m_scene.LoginLock = false; // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); @@ -228,15 +218,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_log.InfoFormat( "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); - if (m_uri != string.Empty) - { - RRAlert("enabled"); - } + m_scene.EventManager.TriggerLoginsEnabled(m_scene); + } + + m_scene.SceneGridService.InformNeighborsThatRegionisUp( + m_scene.RequestModuleInterface(), m_scene.RegionInfo); - m_scene.EventManager.TriggerRegionReady(m_scene); + if (m_uri != string.Empty) + { + RRAlert("enabled"); } - m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + m_scene.EventManager.TriggerRegionReady(m_scene); } public void OarLoadingAlert(string msg) -- cgit v1.1 From 64db0bcbd20ce7487a5f7751ba65d0e2f90b0704 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Jul 2012 23:37:41 +0100 Subject: Add back notification to neighbouring regions when RegionReadyModule is not active accidentally just removed in 528004d --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 00aa0ea..d4ccd41 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1496,6 +1496,9 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerLoginsEnabled(this); } + m_sceneGridService.InformNeighborsThatRegionisUp( + RequestModuleInterface(), RegionInfo); + // Region ready should always be triggered whether logins are immediately enabled or not. EventManager.TriggerRegionReady(this); } -- cgit v1.1 From 6dda7c65ae1d58cac3e8dc2d9d64f56c870df39e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jul 2012 00:09:22 +0100 Subject: Add EventManager.OnRegionLoginsStatusChange fired whenever logins are enabled or disabled at any point, not just during initial startup. This replaces EventManager.OnLoginsEnabled which only fired when logins were first enabled and was affected by a bug where it would never fire if the region started with logins disabled. --- OpenSim/Framework/IScene.cs | 5 +++++ .../Region/CoreModules/World/Access/AccessModule.cs | 10 +++++----- OpenSim/Region/Framework/Scenes/EventManager.cs | 21 +++++++++++---------- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++----- OpenSim/Region/Framework/Scenes/SceneBase.cs | 18 ++++++++++++++++++ .../Scenes/Tests/ScenePresenceTeleportTests.cs | 2 +- .../RegionReadyModule/RegionReadyModule.cs | 4 +--- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- 8 files changed, 47 insertions(+), 25 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index a9432c2..2c38e0f 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -66,6 +66,11 @@ namespace OpenSim.Framework IConfigSource Config { get; } + /// + /// Are logins enabled on this simulator? + /// + bool LoginsEnabled { get; set; } + float TimeDilation { get; } bool AllowScriptCrossings { get; } diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index 553a32d..e7b1454 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs @@ -129,18 +129,18 @@ namespace OpenSim.Region.CoreModules.World switch (cmd[1]) { case "enable": - scene.LoginsDisabled = false; + scene.LoginsEnabled = true; MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); break; case "disable": - scene.LoginsDisabled = true; + scene.LoginsEnabled = false; MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); break; case "status": - if (scene.LoginsDisabled) - MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); - else + if (scene.LoginsEnabled) MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName)); + else + MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); break; default: MainConsole.Instance.Output("Syntax: login enable|disable|status"); diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index b8ae0ac..620b605 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -497,13 +497,14 @@ namespace OpenSim.Region.Framework.Scenes public event RegionHeartbeatEnd OnRegionHeartbeatEnd; /// - /// This should only fire in all circumstances if the RegionReady module is active. + /// Fired when logins to a region are enabled or disabled. /// /// - /// TODO: Fire this even when the RegionReady module is not active. + /// /// - public delegate void LoginsEnabled(IScene scene); - public event LoginsEnabled OnLoginsEnabled; + /// Fired + public event RegionLoginsStatusChange OnRegionLoginsStatusChange; + public delegate void RegionLoginsStatusChange(IScene scene); /// /// Fired when a region is considered ready for use. @@ -512,8 +513,8 @@ namespace OpenSim.Region.Framework.Scenes /// A region is considered ready when startup operations such as loading of scripts already on the region /// have been completed. /// - public delegate void RegionReady(IScene scene); public event RegionReady OnRegionReady; + public delegate void RegionReady(IScene scene); public delegate void PrimsLoaded(Scene s); public event PrimsLoaded OnPrimsLoaded; @@ -2486,13 +2487,13 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerLoginsEnabled(IScene scene) + public void TriggerRegionLoginsStatusChange(IScene scene) { - LoginsEnabled handler = OnLoginsEnabled; + RegionLoginsStatusChange handler = OnRegionLoginsStatusChange; if (handler != null) { - foreach (LoginsEnabled d in handler.GetInvocationList()) + foreach (RegionLoginsStatusChange d in handler.GetInvocationList()) { try { @@ -2500,13 +2501,13 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnLoginsEnabled failed - continuing {0} - {1}", + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}", e.Message, e.StackTrace); } } } } - + public void TriggerRegionReady(IScene scene) { RegionReady handler = OnRegionReady; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d4ccd41..6d8ee7b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -128,9 +128,10 @@ namespace OpenSim.Region.Framework.Scenes // root agents when ACL denies access to root agent public bool m_strictAccessControl = true; public int MaxUndoCount = 5; + // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; public bool LoginLock = false; - public bool LoginsDisabled = true; + public bool StartDisabled = false; public bool LoadingPrims; public IXfer XferManager; @@ -1478,7 +1479,7 @@ namespace OpenSim.Region.Framework.Scenes // landMS = Util.EnvironmentTickCountSubtract(ldMS); //} - if (LoginsDisabled && Frame == 20) + if (!LoginsEnabled && Frame == 20) { // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); @@ -1492,8 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes if (!StartDisabled) { m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); - LoginsDisabled = false; - EventManager.TriggerLoginsEnabled(this); + LoginsEnabled = true; } m_sceneGridService.InformNeighborsThatRegionisUp( @@ -3460,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes agent.startpos ); - if (LoginsDisabled) + if (!LoginsEnabled) { reason = "Logins Disabled"; return false; diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index f50fbfc..282fc5e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -106,6 +106,24 @@ namespace OpenSim.Region.Framework.Scenes protected readonly ClientManager m_clientManager = new ClientManager(); + public bool LoginsEnabled + { + get + { + return m_loginsEnabled; + } + + set + { + if (m_loginsEnabled != value) + { + m_loginsEnabled = value; + EventManager.TriggerRegionLoginsStatusChange(this); + } + } + } + private bool m_loginsEnabled; + public float TimeDilation { get { return 1.0f; } diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index a407f01..37b5184 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -301,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests sp.AbsolutePosition = preTeleportPosition; // Make sceneB refuse CreateAgent - sceneB.LoginsDisabled = true; + sceneB.LoginsEnabled = false; sceneA.RequestTeleportLocation( sp.ControllingClient, diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 8d5b25f..e49ad2a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -210,15 +210,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (!m_scene.StartDisabled) { - m_scene.LoginsDisabled = false; + m_scene.LoginsEnabled = true; // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); m_log.InfoFormat( "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); - - m_scene.EventManager.TriggerLoginsEnabled(m_scene); } m_scene.SceneGridService.InformNeighborsThatRegionisUp( diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 769de83..7598cc3 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -190,7 +190,7 @@ namespace OpenSim.Tests.Common = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); testScene.RegionInfo.EstateSettings = new EstateSettings(); - testScene.LoginsDisabled = false; + testScene.LoginsEnabled = true; testScene.RegisterRegionWithGrid(); SceneManager.Add(testScene); -- cgit v1.1