From ab0630ed815166793e04e0e84fba952afd5e4415 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Thu, 19 May 2011 13:44:15 -0700 Subject: [PATCH] Fixed code in handling setting attachedAvatar when its UUID.Zero. Removed some obselete and debug code. --- .../Avatar/Attachments/AttachmentsModule.cs | 4 +- .../RegionSyncModule/RegionSyncClient.cs | 2 + .../RegionSyncServerModule.cs | 11 -- .../SymmetricSync/RegionSyncModule.cs | 166 ++++-------------- .../Framework/Interfaces/IRegionSyncModule.cs | 28 +-- OpenSim/Region/Framework/Scenes/Scene.cs | 5 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.cs | 3 +- .../Framework/Scenes/SceneObjectPart.cs | 2 +- .../Region/Framework/Scenes/ScenePresence.cs | 3 - 10 files changed, 49 insertions(+), 177 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 8da1dde3aa..8136d797bf 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -567,8 +567,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - m_log.DebugFormat("[ATTACHMENTS MODULE] Region {5}: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, - attachmentpoint, attachOffset, so.RootPart.AttachedPos, m_scene.RegionInfo.RegionName); + m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, + attachmentpoint, attachOffset, so.RootPart.AttachedPos); so.DetachFromBackup(); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index e7222ccd2c..1a07b04919 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -511,10 +511,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_log.ErrorFormat("{0} Caught exception in UpdatedAvatar handler (TrySetMovementAnimation): {1}", LogHeader(), e.Message); } + /* string result = String.Format("Avatar \"{0}\" ({1}) ({2}) updated (pos:{3}, vel:{4}, rot:{5}, fly:{6})", presence.Name, presence.UUID.ToString(), presence.LocalId.ToString(), presence.AbsolutePosition.ToString(), presence.Velocity.ToString(), presence.Rotation.ToString(), presence.PhysicsActor.Flying ? "Y" : "N"); + * */ // RegionSyncMessage.HandleSuccess(LogHeader(), msg, result); return; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index 7a90a52eb7..a880e1f7e0 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -234,9 +234,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_log.DebugFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString()); } - //DSG DEBUG - private Vector3 lastPos; - public void SendUpdates() { if (!Active || !Synced) @@ -300,14 +297,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule presence.lastSentParentID = presence.ParentID; } - //DSG DEBUG - //Vector3 diff = presence.AbsolutePosition - lastPos; - if (Vector3.Distance(presence.AbsolutePosition, lastPos) > 0.1) - { - m_log.DebugFormat("Sending UpdatedAvatar for avatar {0}, with new pos {1}", presence.Name, presence.AbsolutePosition); - lastPos = presence.AbsolutePosition; - } - RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdatedAvatar, OSDParser.SerializeJsonString(data)); m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes()); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index c9de1e5a1b..018cc0fac6 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -196,114 +196,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule get { return m_isSyncRelay; } } - private Dictionary m_primPropertyBucketMap = new Dictionary(); - public Dictionary PrimPropertyBucketMap - { - get { return m_primPropertyBucketMap; } - } - private List m_propertyBucketNames = new List(); - public List PropertyBucketDescription - { - get { return m_propertyBucketNames; } - } - - public void QueueScenePresenceForTerseUpdate(ScenePresence presence) - { - lock (m_updateScenePresenceLock) - { - m_presenceUpdates[presence.UUID] = presence; - } - } - - - - //SendSceneUpdates put each update into an outgoing queue of each SyncConnector - /// - /// Send updates to other sync nodes. So far we only handle object updates. - /// - public void SendSceneUpdates() - { - if (!IsSyncingWithOtherSyncNodes()) - { - //no SyncConnector connected. clear update queues and return. - foreach (string bucketName in m_propertyBucketNames) - { - m_primUpdates[bucketName].Clear(); - } - return; - } - - // Existing value of 1 indicates that updates are currently being sent so skip updates this pass - if (Interlocked.Exchange(ref m_sendingUpdates, 1) == 1) - { - m_log.DebugFormat("[REGION SYNC MODULE] SendUpdates(): An update thread is already running."); - return; - } - - Dictionary> primUpdates = new Dictionary>(); - - bool updated = false; - //copy the updated SOG list and clear m_primUpdates for immediately future usage - foreach (string bucketName in m_propertyBucketNames) - { - if (m_primUpdates[bucketName].Count > 0) - { - //m_log.DebugFormat(m_primUpdates[bucketName].Count + " to send {0} updated parts in bucket {1}", m_primUpdates[bucketName].Count, bucketName); - - lock (m_primUpdateLocks[bucketName]) - { - updated = true; - //primUpdates.Add(bucketName, new List(m_primUpdates[bucketName].Values)); - - //copy the update list - List updateList = new List(); - foreach (SceneObjectPart part in m_primUpdates[bucketName].Values) - { - if (!part.ParentGroup.IsDeleted) - { - //m_log.DebugFormat("include {0},{1} in update list", part.Name, part.UUID); - updateList.Add(part); - } - } - primUpdates.Add(bucketName, updateList); - - m_primUpdates[bucketName].Clear(); - } - } - } - - - if (updated) - { - long timeStamp = DateTime.Now.Ticks; - - // This could be another thread for sending outgoing messages or just have the Queue functions - // create and queue the messages directly into the outgoing server thread. - System.Threading.ThreadPool.QueueUserWorkItem(delegate - { - // Dan's note: Sending the message when it's first queued would yield lower latency but much higher load on the simulator - // as parts may be updated many many times very quickly. Need to implement a higher resolution send in heartbeat - - foreach (string bucketName in m_propertyBucketNames) - { - if (primUpdates.ContainsKey(bucketName) && primUpdates[bucketName].Count > 0) - { - //m_log.Debug(LogHeader + " calling update sender for bucket " + bucketName); - m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]); - primUpdates[bucketName].Clear(); - } - } - - // Indicate that the current batch of updates has been completed - Interlocked.Exchange(ref m_sendingUpdates, 0); - }); - } - else - { - Interlocked.Exchange(ref m_sendingUpdates, 0); - } - } - //The following Sendxxx calls,send out a message immediately, w/o putting it in the SyncConnector's outgoing queue. //May need some optimization there on the priorities. @@ -2654,12 +2546,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_log.DebugFormat("{0}: SendPrimPropertyUpdates for {1}, {2}, with updated properties -- {3}", LogHeader, sop.Name, sop.UUID, pString); //DSG DEBUG - - if (updatedProperties.Contains(SceneObjectPartSyncProperties.AggregateScriptEvents)) + /* + if (updatedProperties.Contains(SceneObjectPartSyncProperties.GroupPosition)) { - // m_log.DebugFormat("SendPrimPropertyUpdates -- AggregateScriptEvents: " + sop.AggregateScriptEvents); + m_log.DebugFormat("SendPrimPropertyUpdates -- prim {0}: GroupPosition: {1} ", sop.Name, sop.GroupPosition); } - + if (updatedProperties.Contains(SceneObjectPartSyncProperties.Position)) + { + m_log.DebugFormat("SendPrimPropertyUpdates -- prim {0}: Position: {1} ", sop.Name, sop.PhysActor.Position); + } + * */ SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedPrimProperties, OSDParser.SerializeJsonString(syncData)); SendPrimUpdateToRelevantSyncConnectors(sop.UUID, syncMsg); @@ -5553,29 +5449,37 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (!part.AttachedAvatar.Equals(attachedAvatar)) { part.AttachedAvatar = attachedAvatar; - Scene localScene = GetLocalScene(); - ScenePresence avatar = localScene.GetScenePresence(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) + if (attachedAvatar != UUID.Zero) { - if (part.ParentGroup != null) + Scene localScene = GetLocalScene(); + ScenePresence avatar = localScene.GetScenePresence(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) { - part.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); - } - else - { - //If this SOP is not a part of group yet, record the - //avatar's localID for now. If this SOP is rootpart of - //the group, then the localID is the right setting; - //otherwise, this SOP will be linked to the SOG it belongs - //to later, and that will rewrite the parent localID. - part.SetParentLocalId(avatar.LocalId); + if (part.ParentGroup != null) + { + part.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); + } + else + { + //If this SOP is not a part of group yet, record the + //avatar's localID for now. If this SOP is rootpart of + //the group, then the localID is the right setting; + //otherwise, this SOP will be linked to the SOG it belongs + //to later, and that will rewrite the parent localID. + part.SetParentLocalId(avatar.LocalId); + } } } + else + { + part.SetParentLocalId(0); + } + } break; case SceneObjectPartSyncProperties.AttachedPos: diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs index 2fa17455a3..7364104a4a 100755 --- a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs @@ -57,41 +57,15 @@ namespace OpenSim.Region.Framework.Interfaces //DSGActorTypes DSGActorType { get; set; } bool IsSyncRelay { get; } - /// - /// The mapping of a property (identified by its name) to the index of a bucket. - /// - Dictionary PrimPropertyBucketMap { get; } - /// - /// The text description of the properties in each bucket, e.g. "General", "Physics" - /// - List PropertyBucketDescription { get; } - - //Enqueue updates for scene-objects and scene-presences - //Legacy interface, used in Bucket-sync - //void QueueSceneObjectPartForUpdate(SceneObjectPart part); - void QueueScenePresenceForTerseUpdate(ScenePresence presence); - - //void ProcessAndEnqueuePrimUpdatesBySync(SceneObjectPart part, List updatedProperties); void ProcessAndEnqueuePrimUpdatesByLocal(SceneObjectPart part, List updatedProperties); void SyncOutPrimUpdates(); - //Legacy calls in Bucket sync'ing - //The folloiwng calls deal with object updates, and will insert each update into an outgoing queue of each SyncConnector - //void SendSceneUpdates(); - //void SendNewObject(SceneObjectGroup sog); - //void SendDeleteObject(SceneObjectGroup sog, bool softDelete); - //void SendLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List children); - //void SendDeLinkObject(List prims, List beforeDelinkGroups, List afterDelinkGroups); - //New functions for per property sync'ing void SyncNewObject(SceneObjectGroup sog); void SyncDeleteObject(SceneObjectGroup sog, bool softDelete); void SyncLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List children); void SyncDeLinkObject(List prims, List beforeDelinkGroups, List afterDelinkGroups); - //In RegionSyncModule's implementation, - //The following calls send out a message immediately, w/o putting it in the SyncConnector's outgoing queue. - //May need some optimization there on the priorities. void SendTerrainUpdates(long updateTimeStamp, string lastUpdateActorID); //For propogating scene events to other actors void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs); @@ -101,7 +75,7 @@ namespace OpenSim.Region.Framework.Interfaces //void QueuePresenceForTerseUpdate(ScenePresence presence) //void SendAvatarUpdates(); - //Debug purpose, mainly for LSL scripts + //Debug purpose, mainly for debugging properties updated by LSL scripts void Debug(String debugMsg); } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7184158a13..b54c362b9f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3700,6 +3700,11 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.RemoveScenePresence(agentID); m_clientManager.Remove(agentID); + //DSG + // We need to keep track of this state in case this group is still queued for sync'ing. + avatar.IsDeleted = true; + //end of DSG + try { avatar.Close(); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e44e28463a..4d179077c6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -434,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes //sceneObject.ScheduleGroupForFullUpdate(); sceneObject.ScheduleGroupForFullUpdate(null); - //DSG SYNC: sending NewObject event, and sending it before calling ScheduleGroupForFullUpdate + //DSG SYNC: sending NewObject event, if (m_parentScene.RegionSyncModule != null && triggerSyncNewObject) { m_parentScene.RegionSyncModule.SyncNewObject(sceneObject); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 56543d13e0..1fb0798208 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -983,7 +983,8 @@ namespace OpenSim.Region.Framework.Scenes AttachToBackup(); m_scene.EventManager.TriggerParcelPrimCountTainted(); //m_rootPart.ScheduleFullUpdate(); - m_rootPart.ScheduleFullUpdate(new List() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint}); //Physics properties, such as Position, OffsetPosition, etc, should be tainted in ApplyPhysics() + m_rootPart.ScheduleFullUpdate(new List() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint, + SceneObjectPartSyncProperties.AttachedAvatar, SceneObjectPartSyncProperties.Flags}); //Physics properties, such as Position, OffsetPosition, etc, should be tainted in ApplyPhysics() m_rootPart.ClearUndoState(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a0c1b1d8f5..a4404c5211 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -773,7 +773,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsAttachment) { - if (m_parentGroup != null) //need to check this, it would be null while deserialization -- IsAttachment is now serialized + if (m_parentGroup != null) { ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); if (sp != null) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c641baa370..623e3dbcfe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2938,9 +2938,6 @@ namespace OpenSim.Region.Framework.Scenes } else if (neighbor > 0) { - //DSG DEBUG - m_log.DebugFormat("{0} now at pos {1}, calling CrossToNewRegion", Name); - if (!CrossToNewRegion()) { if (m_requestedSitTargetUUID == UUID.Zero)