From 9c3c020697cf5710781bb6e491a88bea72652c87 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 1 Jun 2010 15:08:45 +0100 Subject: Lock the object queue when dequeueing --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 159 +++++++++++++------------ 1 file changed, 81 insertions(+), 78 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 15bc33d..5cbd8d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -67,105 +67,108 @@ namespace OpenSim.Region.Framework.Scenes public void SendPrimUpdates() { - if (m_pendingObjects == null) + lock(m_pendingObjects) { - if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) + if (m_pendingObjects == null) { - m_pendingObjects = new Queue(); - - foreach (EntityBase e in m_presence.Scene.Entities) + if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) { - if (e is SceneObjectGroup) - m_pendingObjects.Enqueue((SceneObjectGroup)e); + m_pendingObjects = new Queue(); + + foreach (EntityBase e in m_presence.Scene.Entities) + { + if (e != null && e is SceneObjectGroup) + m_pendingObjects.Enqueue((SceneObjectGroup)e); + } } } - } - - while (m_pendingObjects != null && m_pendingObjects.Count > 0) - { - SceneObjectGroup g = m_pendingObjects.Dequeue(); - // Yes, this can really happen - if (g == null) - continue; - - // This is where we should check for draw distance - // do culling and stuff. Problem with that is that until - // we recheck in movement, that won't work right. - // So it's not implemented now. - // - - // Don't even queue if we have sent this one - // - if (!m_updateTimes.ContainsKey(g.UUID)) - g.ScheduleFullUpdateToAvatar(m_presence); - } - while (m_partsUpdateQueue.Count > 0) - { - SceneObjectPart part = m_partsUpdateQueue.Dequeue(); - - if (part.ParentGroup == null || part.ParentGroup.IsDeleted) - continue; - - if (m_updateTimes.ContainsKey(part.UUID)) + while (m_pendingObjects != null && m_pendingObjects.Count > 0) { - ScenePartUpdate update = m_updateTimes[part.UUID]; + SceneObjectGroup g = m_pendingObjects.Dequeue(); + // Yes, this can really happen + if (g == null) + continue; - // We deal with the possibility that two updates occur at - // the same unix time at the update point itself. + // This is where we should check for draw distance + // do culling and stuff. Problem with that is that until + // we recheck in movement, that won't work right. + // So it's not implemented now. + // + + // Don't even queue if we have sent this one + // + if (!m_updateTimes.ContainsKey(g.UUID)) + g.ScheduleFullUpdateToAvatar(m_presence); + } - if ((update.LastFullUpdateTime < part.TimeStampFull) || - part.IsAttachment) + while (m_partsUpdateQueue.Count > 0) + { + SceneObjectPart part = m_partsUpdateQueue.Dequeue(); + + if (part.ParentGroup == null || part.ParentGroup.IsDeleted) + continue; + + if (m_updateTimes.ContainsKey(part.UUID)) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", -// part.Name, part.UUID, part.TimeStampFull); + ScenePartUpdate update = m_updateTimes[part.UUID]; - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); + // We deal with the possibility that two updates occur at + // the same unix time at the update point itself. - // We'll update to the part's timestamp rather than - // the current time to avoid the race condition - // whereby the next tick occurs while we are doing - // this update. If this happened, then subsequent - // updates which occurred on the same tick or the - // next tick of the last update would be ignored. + if ((update.LastFullUpdateTime < part.TimeStampFull) || + part.IsAttachment) + { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", + // part.Name, part.UUID, part.TimeStampFull); - update.LastFullUpdateTime = part.TimeStampFull; + part.SendFullUpdate(m_presence.ControllingClient, + m_presence.GenerateClientFlags(part.UUID)); - } - else if (update.LastTerseUpdateTime <= part.TimeStampTerse) - { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", -// part.Name, part.UUID, part.TimeStampTerse); + // We'll update to the part's timestamp rather than + // the current time to avoid the race condition + // whereby the next tick occurs while we are doing + // this update. If this happened, then subsequent + // updates which occurred on the same tick or the + // next tick of the last update would be ignored. - part.SendTerseUpdateToClient(m_presence.ControllingClient); + update.LastFullUpdateTime = part.TimeStampFull; - update.LastTerseUpdateTime = part.TimeStampTerse; - } - } - else - { - //never been sent to client before so do full update - ScenePartUpdate update = new ScenePartUpdate(); - update.FullID = part.UUID; - update.LastFullUpdateTime = part.TimeStampFull; - m_updateTimes.Add(part.UUID, update); + } + else if (update.LastTerseUpdateTime <= part.TimeStampTerse) + { + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", + // part.Name, part.UUID, part.TimeStampTerse); - // Attachment handling - // - if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0) + part.SendTerseUpdateToClient(m_presence.ControllingClient); + + update.LastTerseUpdateTime = part.TimeStampTerse; + } + } + else { - if (part != part.ParentGroup.RootPart) + //never been sent to client before so do full update + ScenePartUpdate update = new ScenePartUpdate(); + update.FullID = part.UUID; + update.LastFullUpdateTime = part.TimeStampFull; + m_updateTimes.Add(part.UUID, update); + + // Attachment handling + // + if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0) + { + if (part != part.ParentGroup.RootPart) + continue; + + part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); continue; + } - part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); - continue; + part.SendFullUpdate(m_presence.ControllingClient, + m_presence.GenerateClientFlags(part.UUID)); } - - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); } } } -- cgit v1.1 From a863eb9da3eba3644933b7622239dde641e7050c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 1 Jun 2010 19:01:21 +0200 Subject: One should not lock null objects. --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 5cbd8d9..f478a4a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -67,14 +67,14 @@ namespace OpenSim.Region.Framework.Scenes public void SendPrimUpdates() { - lock(m_pendingObjects) + if (m_pendingObjects == null) { - if (m_pendingObjects == null) + if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) { - if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor)) - { - m_pendingObjects = new Queue(); + m_pendingObjects = new Queue(); + lock(m_pendingObjects) + { foreach (EntityBase e in m_presence.Scene.Entities) { if (e != null && e is SceneObjectGroup) @@ -82,7 +82,10 @@ namespace OpenSim.Region.Framework.Scenes } } } + } + lock(m_pendingObjects) + { while (m_pendingObjects != null && m_pendingObjects.Count > 0) { SceneObjectGroup g = m_pendingObjects.Dequeue(); -- cgit v1.1 From 041f253e2b8ba1d470198849a09979c12b325719 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Jun 2010 18:08:40 +0100 Subject: minor: comment out region interface registration log msg I accidentally left in last week also changes one log message to print out full exception stack trace on both mono/.net instead of just .net --- OpenSim/Region/Framework/Scenes/SceneBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index ee17fbf..f8591ba 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -267,7 +267,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e.ToString()); + m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); } } @@ -376,7 +376,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void RegisterModuleInterface(M mod) { - m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); +// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); List l = null; if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) -- cgit v1.1