From ee7478fa16b95352db22e0eba5c4cb90d47dabd5 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 16 Jul 2012 14:47:03 +0100 Subject: sending more user-friendly messages to the script error window rather than the thrown exceptions. Signed-off-by: Melanie --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3654106..4137397 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1664,9 +1664,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); m_host.AddScriptLPS(1); + UUID objUUID; + if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead. + { + OSSLShoutError("osMessageObject() cannot send messages to objects with invalid UUIDs"); + return; + } + object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; - SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID)); + SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); + + if (sceneOP == null) // prior to patching, PostObjectEvent() would cause a throw exception to be shouted instead. + { + OSSLShoutError("osMessageObject() cannot send message to " + objUUID.ToString() + ", object was not found in scene."); + return; + } m_ScriptEngine.PostObjectEvent( sceneOP.LocalId, new EventParams( -- cgit v1.1 From ed14dac0a38defa64d36e691b12ba6a2e2b8642d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Jul 2012 23:03:23 +0100 Subject: Stop warning about no session from ViewerStats if user teleports to another region in the same simulator that was not next to the source region. This was because teleporting to the new region invoked the new session setup code before the agent was removed from the old region, which then invoked the session teardown code. Now, we only invoke the teardown code if the region ID occupied by the agent being removed is the same as the one registered for the current session. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index faf746f..d1a7217 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -57,7 +57,12 @@ namespace OpenSim.Region.UserStatistics LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static SqliteConnection dbConn; + + /// + /// User statistics sessions keyed by agent ID + /// private Dictionary m_sessions = new Dictionary(); + private List m_scenes = new List(); private Dictionary reports = new Dictionary(); private Dictionary m_simstatsCounters = new Dictionary(); @@ -308,7 +313,6 @@ namespace OpenSim.Region.UserStatistics scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps; scene.EventManager.OnClientClosed += OnClientClosed; scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; - scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; } } } @@ -342,15 +346,11 @@ namespace OpenSim.Region.UserStatistics } } - private void OnMakeChildAgent(ScenePresence agent) - { - } - private void OnClientClosed(UUID agentID, Scene scene) { lock (m_sessions) { - if (m_sessions.ContainsKey(agentID)) + if (m_sessions.ContainsKey(agentID) && m_sessions[agentID].region_id == scene.RegionInfo.RegionID) { m_sessions.Remove(agentID); } -- cgit v1.1 From 217f47b0d5b2382a93f3947e0840056a3ba1abfd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Jul 2012 23:09:48 +0100 Subject: In WebStatsModule.OnMakeRootAgent(), get region ID directly from SP.Scene.RegionInfo.RegionID instead of manually looking it up from the stored scene list. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index d1a7217..ed424ab 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -319,8 +319,6 @@ namespace OpenSim.Region.UserStatistics private void OnMakeRootAgent(ScenePresence agent) { - UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); - lock (m_sessions) { if (!m_sessions.ContainsKey(agent.UUID)) @@ -330,7 +328,7 @@ namespace OpenSim.Region.UserStatistics UserSessionID uid = new UserSessionID(); uid.name_f = agent.Firstname; uid.name_l = agent.Lastname; - uid.region_id = regionUUID; + uid.region_id = agent.Scene.RegionInfo.RegionID; uid.session_id = agent.ControllingClient.SessionId; uid.session_data = usd; @@ -339,7 +337,7 @@ namespace OpenSim.Region.UserStatistics else { UserSessionID uid = m_sessions[agent.UUID]; - uid.region_id = regionUUID; + uid.region_id = agent.Scene.RegionInfo.RegionID; uid.session_id = agent.ControllingClient.SessionId; m_sessions[agent.UUID] = uid; } @@ -395,20 +393,6 @@ namespace OpenSim.Region.UserStatistics return encoding.GetString(buffer); } - private UUID GetRegionUUIDFromHandle(ulong regionhandle) - { - lock (m_scenes) - { - foreach (Scene scene in m_scenes) - { - if (scene.RegionInfo.RegionHandle == regionhandle) - return scene.RegionInfo.RegionID; - } - } - - return UUID.Zero; - } - /// /// Callback for a viewerstats cap /// -- cgit v1.1 From c1667d39a610488e80e9d7c939ee7b449f02410d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Jul 2012 23:15:02 +0100 Subject: refactor: factor out common code in WebStatsModule.OnMakeRootAgent() --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index ed424ab..c11ea02 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -321,26 +321,25 @@ namespace OpenSim.Region.UserStatistics { lock (m_sessions) { + UserSessionID uid; + if (!m_sessions.ContainsKey(agent.UUID)) { UserSessionData usd = UserSessionUtil.newUserSessionData(); - - UserSessionID uid = new UserSessionID(); + uid = new UserSessionID(); uid.name_f = agent.Firstname; uid.name_l = agent.Lastname; - uid.region_id = agent.Scene.RegionInfo.RegionID; - uid.session_id = agent.ControllingClient.SessionId; uid.session_data = usd; m_sessions.Add(agent.UUID, uid); } else { - UserSessionID uid = m_sessions[agent.UUID]; - uid.region_id = agent.Scene.RegionInfo.RegionID; - uid.session_id = agent.ControllingClient.SessionId; - m_sessions[agent.UUID] = uid; + uid = m_sessions[agent.UUID]; } + + uid.region_id = agent.Scene.RegionInfo.RegionID; + uid.session_id = agent.ControllingClient.SessionId; } } -- cgit v1.1 From 1c3b0da74a6e662ceebad53c82d38ba8a42795b3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 16 Jul 2012 23:31:55 +0100 Subject: Revert "Fix script "Running" behavior" A better solution using the already present flags must be found. This reverts commit 6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80. --- OpenSim/Region/Framework/Interfaces/IScriptModule.cs | 2 -- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 -------------- OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | 10 ---------- .../Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 9 --------- .../ScriptEngine/Shared/Instance/ScriptSerializer.cs | 11 ----------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 ------- 6 files changed, 53 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 42dbedc..143af48 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -77,8 +77,6 @@ namespace OpenSim.Region.Framework.Interfaces /// The item ID of the script. bool GetScriptState(UUID itemID); - void SetRunEnable(UUID instanceID, bool enable); - void SaveAllState(); /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9ff8467..e413281 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2143,24 +2143,10 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - IScriptModule[] engines = RequestModuleInterfaces(); - if (running) - { - foreach (IScriptModule engine in engines) - { - engine.SetRunEnable(itemID, true); - } EventManager.TriggerStartScript(part.LocalId, itemID); - } else - { - foreach (IScriptModule engine in engines) - { - engine.SetRunEnable(itemID, false); - } EventManager.TriggerStopScript(part.LocalId, itemID); - } } public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index ec13b6c..b04f6b6 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -64,16 +64,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces bool Running { get; set; } /// - /// Gets or sets a value indicating whether this - /// is run. - /// For viewer script editor control - /// - /// - /// true if run; otherwise, false. - /// - bool Run { get; set; } - - /// /// Is the script suspended? /// bool Suspended { get; set; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f1abd4b..d570ef7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -121,8 +121,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public bool Running { get; set; } - public bool Run { get; set; } - public bool Suspended { get { return m_Suspended; } @@ -218,7 +216,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_postOnRez = postOnRez; m_AttachedAvatar = part.ParentGroup.AttachedAvatar; m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; - Run = true; if (part != null) { @@ -360,9 +357,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (m_startedFromSavedState) { - if (!Run) - return; - Start(); if (m_postOnRez) { @@ -395,9 +389,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else { - if (!Run) - return; - Start(); PostEvent(new EventParams("state_entry", new Object[0], new DetectParams[0])); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs index 797bce3..bcdc7bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs @@ -55,7 +55,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public static string Serialize(ScriptInstance instance) { bool running = instance.Running; - bool enabled = instance.Run; XmlDocument xmldoc = new XmlDocument(); @@ -78,12 +77,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance rootElement.AppendChild(run); - XmlElement run_enable = xmldoc.CreateElement("", "Run", ""); - run_enable.AppendChild(xmldoc.CreateTextNode( - enabled.ToString())); - - rootElement.AppendChild(run_enable); - Dictionary vars = instance.GetVars(); XmlElement variables = xmldoc.CreateElement("", "Variables", ""); @@ -232,7 +225,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { object varValue; XmlNodeList partL = rootNode.ChildNodes; - instance.Run = true; foreach (XmlNode part in partL) { @@ -244,9 +236,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance case "Running": instance.Running=bool.Parse(part.InnerText); break; - case "Run": - instance.Run = bool.Parse(part.InnerText); - break; case "Variables": XmlNodeList varL = part.ChildNodes; foreach (XmlNode var in varL) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 20fad05..01aebb6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1541,13 +1541,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public void SetRunEnable(UUID instanceID, bool enable) - { - IScriptInstance instance = GetInstance(instanceID); - if (instance != null) - instance.Run = enable; - } - public bool GetScriptState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); -- cgit v1.1 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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