From 51ec2d83ac6a609ce6757af2b04fcd1e9cfd769d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 22:43:17 +0100 Subject: [PATCH 01/10] remove redundant code --- .../Scenes/SceneObjectPartInventory.cs | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7328a398cf..147d530c5c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -505,35 +505,22 @@ namespace OpenSim.Region.Framework.Scenes private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { m_items.LockItemsForRead(true); + if (m_items.ContainsKey(itemId)) { - if (m_items.ContainsKey(itemId)) - { - m_items.LockItemsForRead(false); - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); - } - else - { - m_items.LockItemsForRead(false); - string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, - m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); - StoreScriptError(itemId, msg); - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it {1}", itemId, msg); - } + m_items.LockItemsForRead(false); + CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); } else { m_items.LockItemsForRead(false); - string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); + string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, + m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); StoreScriptError(itemId, msg); m_log.ErrorFormat( - "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", - itemId, m_part.Name, m_part.UUID, - m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); + "[PRIM INVENTORY]: " + + "Couldn't start script with ID {0} since it {1}", itemId, msg); } - } /// From adda696cd09426c4d59c2850cd6ae3bab52fbf6d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 22:46:44 +0100 Subject: [PATCH 02/10] protect getting the item --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 147d530c5c..5b167a2ed8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -508,8 +508,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_items.ContainsKey(itemId)) { + TaskInventoryItem it = m_items[itemId]; m_items.LockItemsForRead(false); - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); + + CreateScriptInstance(it, startParam, postOnRez, engine, stateSource); } else { From f95bb533719bd80cfecb5f82e735230a0317bbc6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:02:02 +0100 Subject: [PATCH 03/10] remove LockItemsForRead(false) without previus call with true --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 -- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ca682d397b..eb6cf23861 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5283,7 +5283,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return item.AssetID.ToString(); } - m_host.TaskInventory.LockItemsForRead(false); return UUID.Zero.ToString(); } @@ -10203,7 +10202,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case 4: return (int)item.NextPermissions; } - m_host.TaskInventory.LockItemsForRead(false); return -1; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7081416d08..d2a59807da 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -991,7 +991,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else animID = UUID.Zero; } - m_host.TaskInventory.LockItemsForRead(false); + if (animID == UUID.Zero) target.Animator.RemoveAnimation(animation); From d1ccc6d5cc6488939b8f35d1c84a9c6d5d675b76 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:23:20 +0100 Subject: [PATCH 04/10] release lock a bit sooner when not needed, add a try on more complex db store call --- .../Framework/Scenes/SceneObjectPartInventory.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5b167a2ed8..aeec54e683 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1133,26 +1133,28 @@ namespace OpenSim.Region.Framework.Scenes if (m_inventorySerial == 0) // No inventory { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); Items.LockItemsForRead(false); + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); + return; } if (m_items.Count == 0) // No inventory { - client.SendTaskInventory(m_part.UUID, 0, new byte[0]); Items.LockItemsForRead(false); + client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } if (!changed) { + Items.LockItemsForRead(false); + xferManager.AddNewFile(filename, m_inventoryFileData); client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, Util.StringToBytes256(filename)); - Items.LockItemsForRead(false); return; } @@ -1238,7 +1240,12 @@ namespace OpenSim.Region.Framework.Scenes // if (HasInventoryChanged) // { Items.LockItemsForRead(true); - datastore.StorePrimInventory(m_part.UUID, Items.Values); + try + { + datastore.StorePrimInventory(m_part.UUID, Items.Values); + } + catch(){} + Items.LockItemsForRead(false); HasInventoryChanged = false; From a70ed79c392ea25b4476401c7250402745fa0287 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:26:17 +0100 Subject: [PATCH 05/10] compile fix --- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index aeec54e683..2fa91398d6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1244,11 +1244,13 @@ namespace OpenSim.Region.Framework.Scenes { datastore.StorePrimInventory(m_part.UUID, Items.Values); } - catch(){} - - Items.LockItemsForRead(false); + catch {} HasInventoryChanged = false; + + Items.LockItemsForRead(false); + + // } } From e25849e1c46c9db61d5a44e3a696fdf7a934892b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Sep 2014 23:39:50 +0100 Subject: [PATCH 06/10] remove redundant lock --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index f7436635ed..cc844aef76 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -308,7 +308,8 @@ namespace OpenSim.Data.MySQL /// the Item UUID private void RemoveItems(UUID uuid) { - lock (m_dbLock) + // locked by caller +// lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { From bcaf202e34ab058a049c921e1279793d61eef5ea Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 13:59:23 +0100 Subject: [PATCH 07/10] update scenegraph group find by part information in sog link, so script link functions do update that also. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 21 ++++++++++++++++--- .../Framework/Scenes/SceneObjectGroup.cs | 8 ++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55e7da450c..c583ce750e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2548,6 +2548,11 @@ namespace OpenSim.Region.Framework.Scenes return false; } + + public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) + { + m_sceneGraph.updateScenePartGroup(part, grp); + } /// /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 973891bc5c..bc91961ed4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -462,6 +462,20 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) + { + // no tests, caller has responsability... + lock (SceneObjectGroupsByFullPartID) + { + SceneObjectGroupsByFullPartID[part.UUID] = grp; + } + + lock (SceneObjectGroupsByLocalPartID) + { + SceneObjectGroupsByLocalPartID[part.LocalId] = grp; + } + } + /// /// Delete an object from the scene /// @@ -1804,7 +1818,7 @@ namespace OpenSim.Region.Framework.Scenes List childGroups = new List(); // We do this in reverse to get the link order of the prims correct - for (int i = 0 ; i < children.Count ; i++) + for (int i = 0; i < children.Count; i++) { SceneObjectGroup child = children[i].ParentGroup; @@ -1815,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes // Make sure no child prim is set for sale // So that, on delink, no prims are unwittingly // left for sale and sold off - + if (child != null) { child.RootPart.ObjectSaleType = 0; @@ -1850,12 +1864,13 @@ namespace OpenSim.Region.Framework.Scenes } finally { +/* lock (SceneObjectGroupsByLocalPartID) { foreach (SceneObjectPart part in parentGroup.Parts) SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - +*/ parentGroup.AdjustChildPrimPermissions(); parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 15349e30a7..b939b58fd6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2560,11 +2560,8 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - // give new ID to the new part, letting old keep original - // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); newPart.LocalId = m_scene.AllocateLocalId(); - newPart.SetParent(this); AddPart(newPart); @@ -2977,6 +2974,8 @@ namespace OpenSim.Region.Framework.Scenes m_parts.Add(linkPart.UUID, linkPart); linkPart.SetParent(this); + m_scene.updateScenePartGroup(linkPart, this); + linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now @@ -3238,9 +3237,12 @@ namespace OpenSim.Region.Framework.Scenes part.SetParent(this); part.ParentID = m_rootPart.LocalId; m_parts.Add(part.UUID, part); + part.LinkNum = linkNum; + m_scene.updateScenePartGroup(part, this); + // Compute the new position of this SOP relative to the group position part.OffsetPosition = newPos - AbsolutePosition; From fe3c1b9e98d9100a6ae04f077644e0c3790f6b4d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 14:32:56 +0100 Subject: [PATCH 08/10] send to world or backup, after setting finding information --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index bc91961ed4..fe785dde11 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -432,13 +432,9 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); - if (sendClientUpdates) - sceneObject.ScheduleGroupForFullUpdate(); Entities.Add(sceneObject); - if (attachToBackup) - sceneObject.AttachToBackup(); lock (SceneObjectGroupsByFullID) SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; @@ -459,6 +455,12 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; } + if (sendClientUpdates) + sceneObject.ScheduleGroupForFullUpdate(); + + if (attachToBackup) + sceneObject.AttachToBackup(); + return true; } From b7fca5bcac4e26ec6381e6fc7d085149e8cbc869 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 14:44:47 +0100 Subject: [PATCH 09/10] same in a few more spots --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fe785dde11..f4ff902374 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -296,13 +296,15 @@ namespace OpenSim.Region.Framework.Scenes } } + bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + if (attachToBackup && (!alreadyPersisted)) { sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; } - return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + return ret; } /// @@ -319,12 +321,17 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - // Ensure that we persist this new scene object if it's not an + + + bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + + // Ensure that we persist this new scene object if it's not an // attachment + if (attachToBackup) sceneObject.HasGroupChanged = true; - return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); + return ret; } /// From ea4a526095c7797e3863f540abb8d439dac3f9d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Sep 2014 16:09:39 +0100 Subject: [PATCH 10/10] a few more changes on link/unlink --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 17 +++++++---------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f4ff902374..8a65b06414 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1962,20 +1962,17 @@ namespace OpenSim.Region.Framework.Scenes // slated for unlink, we need to do this // Unlink the remaining set // - bool sendEventsToRemainder = true; - if (numChildren > 1) - sendEventsToRemainder = false; + bool sendEventsToRemainder = false; + if (numChildren == 2) // only one child prim no re-link needed + sendEventsToRemainder = true; foreach (SceneObjectPart p in newSet) { if (p != group.RootPart) { group.DelinkFromGroup(p, sendEventsToRemainder); - if (numChildren > 2) - { - } - else - { + if (sendEventsToRemainder) // finish single child prim now + { p.ParentGroup.HasGroupChanged = true; p.ParentGroup.ScheduleGroupForFullUpdate(); } @@ -2008,8 +2005,8 @@ namespace OpenSim.Region.Framework.Scenes newChild.ClearUpdateSchedule(); LinkObjects(newRoot, newSet); - if (!affectedGroups.Contains(newRoot.ParentGroup)) - affectedGroups.Add(newRoot.ParentGroup); +// if (!affectedGroups.Contains(newRoot.ParentGroup)) +// affectedGroups.Add(newRoot.ParentGroup); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b939b58fd6..ca6f457fdf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3177,9 +3177,6 @@ namespace OpenSim.Region.Framework.Scenes m_scene.AddNewSceneObject(objectGroup, true); - if (sendEvents) - linkPart.TriggerScriptChangedEvent(Changed.LINK); - linkPart.Rezzed = RootPart.Rezzed; // When we delete a group, we currently have to force persist to the database if the object id has changed @@ -3194,6 +3191,9 @@ namespace OpenSim.Region.Framework.Scenes objectGroup.HasGroupChangedDueToDelink = true; + if (sendEvents) + linkPart.TriggerScriptChangedEvent(Changed.LINK); + return objectGroup; }