From 5af108a029e5382f6a2f6d4d10b3d4de3a8f5245 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 21 May 2008 21:22:56 +0000 Subject: * This update causes the backup process to run in a separate thread. * Concurrency issues are resolved because each object makes a memory-only copy of itself and backs up the copy. * Because of the way this is done, the latest at the time of the backup gets backed up (no functionality change) * You can move *thousands of objects at a time* and the sim doesn't freeze and wait for the backup to complete. * This can be enhanced more by dedicating the thread as opposed to starting it when the backup process starts. --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 65 +++++++++++++++------- 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 44e4c81..4b82bf9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1085,13 +1085,24 @@ namespace OpenSim.Region.Environment.Scenes /// public void ProcessBackup(IRegionDataStore datastore) { - if (HasGroupChanged) + // don't backup while it's selected or you're asking for changes mid stream. + if (HasGroupChanged && !IsSelected) { - datastore.StoreObject(this, m_scene.RegionInfo.RegionID); + m_log.Info("STORING"); + SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false); + + datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); HasGroupChanged = false; + + backup_group.ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); }); + + backup_group = null; } + + // Why is storing the inventory outside of HasGroupChanged? - ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); }); + + //ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); }); } #endregion @@ -1165,7 +1176,7 @@ namespace OpenSim.Region.Environment.Scenes /// Duplicates this object, including operations such as physics set up and attaching to the backup event. /// /// - public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID) + public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID, bool userExposed) { SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone(); dupe.m_parts = new Dictionary(); @@ -1176,11 +1187,13 @@ namespace OpenSim.Region.Environment.Scenes dupe.m_scene = m_scene; dupe.m_regionHandle = m_regionHandle; - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID); - dupe.m_rootPart.TrimPermissions(); + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + + if (userExposed) + dupe.m_rootPart.TrimPermissions(); /// may need to create a new Physics actor. - if (dupe.RootPart.PhysActor != null) + if (dupe.RootPart.PhysActor != null && userExposed) { PrimitiveBaseShape pbs = dupe.RootPart.Shape; @@ -1202,26 +1215,36 @@ namespace OpenSim.Region.Environment.Scenes // switch the owner to the person who did the copying // Second Life copies an object and duplicates the first one in it's place // So, we have to make a copy of this one, set it in it's place then set the owner on this one + if (userExposed) + { + SetRootPartOwner(m_rootPart, cAgentID, cGroupID); + m_rootPart.ScheduleFullUpdate(); + } - SetRootPartOwner(m_rootPart, cAgentID, cGroupID); - - - m_rootPart.ScheduleFullUpdate(); + List partList = new List(m_parts.Values); foreach (SceneObjectPart part in partList) { if (part.UUID != m_rootPart.UUID) { - dupe.CopyPart(part, OwnerID, GroupID); - SetPartOwner(part, cAgentID, cGroupID); - part.ScheduleFullUpdate(); + dupe.CopyPart(part, OwnerID, GroupID, userExposed); + + if (userExposed) + { + SetPartOwner(part, cAgentID, cGroupID); + part.ScheduleFullUpdate(); + } } } - dupe.UpdateParentIDs(); - dupe.AttachToBackup(); - ScheduleGroupForFullUpdate(); + if (userExposed) + { + dupe.UpdateParentIDs(); + + dupe.AttachToBackup(); + ScheduleGroupForFullUpdate(); + } return dupe; } @@ -1232,9 +1255,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void CopyRootPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) + public void CopyRootPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count); + SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count, userExposed); newPart.SetParent(this); lock (m_parts) @@ -1364,9 +1387,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void CopyPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) + public void CopyPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count); + SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count, userExposed); newPart.SetParent(this); lock (m_parts) -- cgit v1.1