From c0c9a1d9da30b07c149a65ccfa3483c14585bc08 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 15 Jun 2011 09:55:52 -0700 Subject: [PATCH 1/4] Line ending convertion. --- .../World/AutoBackup/AutoBackupModuleState.cs | 202 +++++++++--------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs index 2db718c413..f9e118b23c 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs @@ -23,104 +23,104 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; - - -namespace OpenSim.Region.OptionalModules.World.AutoBackup -{ - /// AutoBackupModuleState: Auto-Backup state for one region (scene). - /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque. - /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation. - /// - /// - public class AutoBackupModuleState - { - private Dictionary m_liveRequests = null; - - public AutoBackupModuleState() - { - this.Enabled = false; - this.BackupDir = "."; - this.BusyCheck = true; - this.Timer = null; - this.NamingType = NamingType.Time; - this.Script = null; - } - - public Dictionary LiveRequests - { - get { - return this.m_liveRequests ?? - (this.m_liveRequests = new Dictionary(1)); - } - } - - public bool Enabled - { - get; - set; - } - - public System.Timers.Timer Timer - { - get; - set; - } - - public double IntervalMinutes - { - get - { - if (this.Timer == null) - { - return -1.0; - } - else - { - return this.Timer.Interval / 60000.0; - } - } - } - - public bool BusyCheck - { - get; - set; - } - - public string Script - { - get; - set; - } - - public string BackupDir - { - get; - set; - } - - public NamingType NamingType - { - get; - set; - } - - public new string ToString() - { - string retval = ""; - - retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; - retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n"; - retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n"; - retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; - retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n"; - retval += "[AUTO BACKUP]: Script: " + Script + "\n"; - return retval; - } - } -} - + */ + +using System; +using System.Collections.Generic; + + +namespace OpenSim.Region.OptionalModules.World.AutoBackup +{ + /// AutoBackupModuleState: Auto-Backup state for one region (scene). + /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque. + /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation. + /// + /// + public class AutoBackupModuleState + { + private Dictionary m_liveRequests = null; + + public AutoBackupModuleState() + { + this.Enabled = false; + this.BackupDir = "."; + this.BusyCheck = true; + this.Timer = null; + this.NamingType = NamingType.Time; + this.Script = null; + } + + public Dictionary LiveRequests + { + get { + return this.m_liveRequests ?? + (this.m_liveRequests = new Dictionary(1)); + } + } + + public bool Enabled + { + get; + set; + } + + public System.Timers.Timer Timer + { + get; + set; + } + + public double IntervalMinutes + { + get + { + if (this.Timer == null) + { + return -1.0; + } + else + { + return this.Timer.Interval / 60000.0; + } + } + } + + public bool BusyCheck + { + get; + set; + } + + public string Script + { + get; + set; + } + + public string BackupDir + { + get; + set; + } + + public NamingType NamingType + { + get; + set; + } + + public new string ToString() + { + string retval = ""; + + retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; + retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n"; + retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n"; + retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; + retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n"; + retval += "[AUTO BACKUP]: Script: " + Script + "\n"; + return retval; + } + } +} + From c46f8ab291d261ee2bcb33e92b96e4afba2a23bf Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Thu, 16 Jun 2011 14:19:46 -0700 Subject: [PATCH 2/4] Line ending conversion. --- .../RegionSyncModule/SymmetricSync/RegionSyncModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 42045bb962..e1cde8ba1d 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -4425,7 +4425,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule XmlTextReader reader = new XmlTextReader(sr); PrimitiveBaseShape shapeValue; try - { + { bool errors = false; shapeValue = SceneObjectSerializer.ReadShape(reader, "Shape", out errors); } From f029bd7782f177933f9d35bdd2591d8b8fc080ed Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Thu, 30 Jun 2011 16:44:01 -0700 Subject: [PATCH 3/4] Reimplement AddNewSceneObjectBySync in SceneGraph.cs and DeleteSceneObjectBySync in Scene.cs, so that they are eventually calling OpenSim's implementation of AddSceneObject and DeleteSceneObject. Also, fixed a bug in syncing position of attachments. --- .../SymmetricSync/ClientManagerSyncModule.cs | 9 ++--- .../SymmetricSync/PhysicsEngineSyncModule.cs | 4 +-- .../SymmetricSync/RegionSyncModule.cs | 22 +++++++++--- .../ScenePersistenceSyncModule.cs | 3 +- .../SymmetricSync/ScriptEngineSyncModule.cs | 2 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 32 ++++++++++++++--- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 34 +++++++++++++++++++ 7 files changed, 85 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs index e4c7bfdec2..66fe933675 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs @@ -108,8 +108,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //Register for Scene/SceneGraph events - //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ClientManager_OnObjectCreate); - m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ClientManager_OnObjectCreateBySync); m_scene.EventManager.OnSymmetricSyncStop += ClientManager_OnSymmetricSyncStop; } @@ -173,19 +171,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private string LogHeader = "[ClientManagerSyncModule]"; /// - /// Script Engine's action upon an object is added to the local scene + /// Client Manager's action upon an object is added to the local scene /// private void ClientManager_OnObjectCreateBySync(EntityBase entity) { - if (entity is SceneObjectGroup) - { - } } public void ClientManager_OnSymmetricSyncStop() { //remove all objects - m_scene.DeleteAllSceneObjects(); + //m_scene.DeleteAllSceneObjects(); } #endregion //ScriptEngineSyncModule diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs index c20c14dae7..e305901a33 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs @@ -115,8 +115,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //Register for Scene/SceneGraph events - //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(PhysicsEngine_OnObjectCreate); - m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(PhysicsEngine_OnObjectCreateBySync); m_scene.EventManager.OnSymmetricSyncStop += PhysicsEngine_OnSymmetricSyncStop; } @@ -180,7 +178,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private string LogHeader = "[PhysicsEngineSyncModule]"; /// - /// Script Engine's action upon an object is added to the local scene + /// Physics Engine's action upon an object is added to the local scene /// private void PhysicsEngine_OnObjectCreateBySync(EntityBase entity) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 1dca38ba52..c62bc5aab9 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -1880,8 +1880,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule shape = true; } } - m_log.WarnFormat("{0}: HandleUpdatedPrimProperties -- prim {1} not in local SceneGraph. SOP == NULL? ({2}), Sender is {3}, property == Shape? {4}", - LogHeader, primUUID, sop == null, senderActorID, shape); + //m_log.WarnFormat("{0}: HandleUpdatedPrimProperties -- prim {1} not in local SceneGraph. SOP == NULL? ({2}), Sender is {3}, property == Shape? {4}", + // LogHeader, primUUID, sop == null, senderActorID, shape); return; } @@ -2198,7 +2198,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_primSyncInfoManager.RemovePrimSyncInfo(part); } - m_scene.DeleteSceneObjectBySynchronization(sog); + m_scene.DeleteSceneObjectBySync(sog); } else { @@ -3531,6 +3531,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SceneObjectGroup group; Dictionary primsSyncInfo; + SceneObjectDecoder(data, out group, out primsSyncInfo); if (group == null) @@ -3585,7 +3586,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap rootData = (OSDMap)data["RootPart"]; //Decode and copy to the list of PrimSyncInfo - PrimSyncInfo primSyncInfo = m_primSyncInfoManager.DecodeFullSetPrimProperties(rootData); + PrimSyncInfo primSyncInfo = null; + try + { + primSyncInfo = m_primSyncInfoManager.DecodeFullSetPrimProperties(rootData); + } + catch (Exception e) + { + m_log.ErrorFormat("SceneObjectDecoder: {0}", e.Message); + return; + } SceneObjectPart root= primSyncInfo.PrimSyncInfoToSOP(); if (root != null) @@ -6768,6 +6778,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule part.ParentGroup.AbsolutePosition = (Vector3)pSyncInfo.LastUpdateValue; PropertySyncInfo gPosSyncInfo; + + if (part.IsAttachment) + return; + if (m_propertiesSyncInfo.ContainsKey(SceneObjectPartSyncProperties.GroupPosition)) { gPosSyncInfo = m_propertiesSyncInfo[SceneObjectPartSyncProperties.GroupPosition]; diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs index b8e9ef614c..7142604ef0 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Register for Scene/SceneGraph events m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScenePersistence_OnObjectCreate); - m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync); + //m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync); } //Called after AddRegion() has been called for all region modules of the scene. @@ -124,7 +124,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (!m_active) return; m_log.Warn(LogHeader + " RegionLoaded() called"); - } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs index 09bfa255fa..3bcfed1e71 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs @@ -109,6 +109,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Register for Scene/SceneGraph events //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate); + + //Don't subscribe to OnObjectCreate, only subscribe OnObjectCreateBySync. m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScriptEngine_OnObjectCreateBySync); m_scene.EventManager.OnSymmetricSyncStop += ScriptEngine_OnSymmetricSyncStop; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d36cc85adc..f12527baec 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -702,16 +702,20 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup sog = (SceneObjectGroup)e; if (!sog.IsAttachment) - DeleteSceneObjectBySynchronization((SceneObjectGroup)e); + DeleteSceneObjectBySync((SceneObjectGroup)e); } } } } //Similar to DeleteSceneObject, except that this does not trigger SyncDeleteObject - public void DeleteSceneObjectBySynchronization(SceneObjectGroup group) + public void DeleteSceneObjectBySync(SceneObjectGroup group) { + bool silent = false; + bool syncDelete = false; + DeleteSceneObject(group, silent, syncDelete); + /* // Serialise calls to RemoveScriptInstances to avoid // deadlocking on m_parts inside SceneObjectGroup lock (m_deleting_scene_object) @@ -743,6 +747,7 @@ namespace OpenSim.Region.Framework.Scenes bool silent = false; //do not suppress broadcasting changes to other clients, for debugging with viewers group.DeleteGroupFromScene(silent); + * */ } public void AddNewSceneObjectPartBySync(SceneObjectPart newPart, SceneObjectGroup parentGroup) @@ -753,6 +758,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.AddNewSceneObjectPart(newPart, parentGroup); } + public ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup sceneObject) { //if(attachToBackup) @@ -790,7 +796,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - return m_sceneGraph.AddNewSceneObjectBySync(sceneObject); + if (m_sceneGraph.AddNewSceneObjectBySync(sceneObject)) + return Scene.ObjectUpdateResult.New; + else + return Scene.ObjectUpdateResult.Error; } //return m_sceneGraph.AddNewSceneObjectBySync(group); @@ -2668,12 +2677,25 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Synchronously delete the given object from the scene. This should be called by + /// deletion that is initiated locally. + /// + /// + /// + public void DeleteSceneObject(SceneObjectGroup group, bool silent) + { + DeleteSceneObject(group, silent, true); + } + /// /// Synchronously delete the given object from the scene. /// /// Object Id /// Suppress broadcasting changes to other clients. - public void DeleteSceneObject(SceneObjectGroup group, bool silent) + /// "false" if this function is called by + /// receiving SymmetricSyncMessage.MsgType.RemovedObject, "true" otherwise. + public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool syncDelete) { // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); @@ -2715,7 +2737,7 @@ namespace OpenSim.Region.Framework.Scenes //DSG SYNC //Propagate the RemovedObject message - if (RegionSyncModule != null) + if (RegionSyncModule != null && syncDelete) { //RegionSyncModule.SendDeleteObject(group, false); RegionSyncModule.SyncDeleteObject(group, false); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index cd87f6bfed..86a65692c5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2096,6 +2096,7 @@ namespace OpenSim.Region.Framework.Scenes */ //This is called when an object is added due to receiving a state synchronization message from Scene or an actor. Do similar things as the original AddSceneObject(), //but call ScheduleGroupForFullUpdate_TimeStampUnchanged() instead, so as not to modify the timestamp or actorID, since the object was not created locally. + /* public Scene.ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup sceneObject) { Scene.ObjectUpdateResult updateResult = Scene.ObjectUpdateResult.New; @@ -2185,6 +2186,7 @@ namespace OpenSim.Region.Framework.Scenes return updateResult; } + * */ public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup) { @@ -2534,6 +2536,38 @@ namespace OpenSim.Region.Framework.Scenes return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates, triggerSyncNewObject); } + protected internal bool AddNewSceneObjectBySync(SceneObjectGroup sceneObject) + { + sceneObject.HasGroupChanged = true; + bool triggerSyncNewObject = false; + if (AddSceneObject(sceneObject, true, true, triggerSyncNewObject)) + { + //Take some special care of the case of this object being an attachment, + //since localID of attachedAvatar is different in different sync node's + //Scene copies. + sceneObject.RootPart.SetAttachmentPoint(sceneObject.RootPart.AttachmentPoint); + if (sceneObject.IsAttachment) + { + ScenePresence avatar = m_parentScene.GetScenePresence(sceneObject.RootPart.AttachedAvatar); + //It is possible that the avatar has not been fully + //created locally when attachment objects are sync'ed. + //So we need to check if the avatar already exists. + //If not, handling of NewAvatar will evetually trigger + //calling of SetParentLocalId. + if (avatar != null) + sceneObject.RootPart.SetParentLocalId(avatar.LocalId); + } + + sceneObject.HasGroupChanged = true; + sceneObject.ScheduleGroupForFullUpdate(null); + + if (OnObjectCreateBySync != null) + OnObjectCreateBySync(sceneObject); + return true; + } + return false; + } + #endregion //DSG SYNC } } From 5a78c715ea74616e98b27645352c488ae12bec63 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 13 Jul 2011 10:42:25 -0700 Subject: [PATCH 4/4] reorder the lookup of physics actor since looking up a SOG by UUID is VERY slow if the SOG does not exist --- .../RegionSyncModule/PhysEngineToSceneConnector.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs index 417b39f224..76a6ed1043 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs @@ -394,16 +394,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Find the physics actor whether it is an object or a scene presence private PhysicsActor FindPhysicsActor(UUID uuid) { - SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); - if (sop != null) - { - return sop.PhysActor; - } ScenePresence sp = m_validLocalScene.GetScenePresence(uuid); if (sp != null) { return sp.PhysicsActor; } + SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); + if (sop != null) + { + return sop.PhysActor; + } return null; }