From 972b0b52f9acedf13114fbed2ec35bb63adeea79 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Jun 2012 21:30:36 +0100 Subject: [PATCH 1/9] If rest of first line after colon is blank then still warn about running in XEngine if engine specified does not exist. This is to take account of situations where the user was intending to specify a script engine using colon using its default language. This probably generates few false positive as scripts are less likely to end a first line colon with a comment for other purposes. --- .../Region/ScriptEngine/XEngine/XEngine.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a709be34f6..35fac4e57a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -780,27 +780,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (engine == ScriptEngineName) { // If we are falling back on XEngine as the default engine, then only complain to the user - // if a script language has been explicitly set and it's one that we recognize. If it's + // if a script language has been explicitly set and it's one that we recognize or there are + // no non-whitespace characters after the colon. + // + // If the script is // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. // + // If the colon ends the line then we'll risk the false positive as this is more likely + // to signal a real scriptengine line where the user wants to use the default compile language. + // // This avoids the overwhelming number of false positives where we're in this code because // there's a colon in a comment in the first line of a script for entirely // unrelated reasons (e.g. vim settings). // // TODO: A better fix would be to deprecate simple : detection and look for some less likely // string to begin the comment (like #! in unix shell scripts). - bool scriptExplicitlyInXEngineLanguage = false; - string restOfScript = script.Substring(colon + 1); + bool warnRunningInXEngine = false; + string restOfFirstLine = firstline.Substring(colon + 1); // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs - if (restOfScript.StartsWith("c#") - || restOfScript.StartsWith("vb") - || restOfScript.StartsWith("lsl") - || restOfScript.StartsWith("js") - || restOfScript.StartsWith("yp")) - scriptExplicitlyInXEngineLanguage = true; + if (restOfFirstLine.StartsWith("c#") + || restOfFirstLine.StartsWith("vb") + || restOfFirstLine.StartsWith("lsl") + || restOfFirstLine.StartsWith("js") + || restOfFirstLine.StartsWith("yp") + || restOfFirstLine.Length == 0) + warnRunningInXEngine = true; - if (scriptExplicitlyInXEngineLanguage) + if (warnRunningInXEngine) { SceneObjectPart part = m_Scene.GetSceneObjectPart( From f263d6a910f5c382756da04dd423db4a46b1eeb7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Jun 2012 22:48:49 +0100 Subject: [PATCH 2/9] Remove code that tried to delete an attachment back to inventory if RezSingleAttachmentFromInventoryInternal() returned null. null would only ever be returned if the item couldn't be located within inventory and this would happen immediately. In this case, derezzing wouldn't work anyway since there is no item to derez. --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 4a7fbcee96..e3ee2fcc04 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -365,12 +365,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return null; } - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); - - if (att == null) - DetachSingleAttachmentToInv(sp, itemID); - - return att; + return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); } public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List> rezlist) From 571fd966cbcb4e718703bc194384f6bf84c211df Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Jun 2012 23:01:12 +0100 Subject: [PATCH 3/9] Rather than iterating through all SOGs in the scene looking for the one that matches out fromItemID on detach, go through the agent's attachment sog list instead. --- .../Avatar/Attachments/AttachmentsModule.cs | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e3ee2fcc04..e9f0488396 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -666,34 +666,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (itemID == UUID.Zero) // If this happened, someone made a mistake.... return; - // We can NOT use the dictionries here, as we are looking - // for an entity by the fromAssetID, which is NOT the prim UUID - EntityBase[] detachEntities = m_scene.GetEntities(); - SceneObjectGroup group; - lock (sp.AttachmentsSyncLock) { - foreach (EntityBase entity in detachEntities) + List attachments = sp.GetAttachments(); + + foreach (SceneObjectGroup group in attachments) { - if (entity is SceneObjectGroup) + if (group.FromItemID == itemID) { - group = (SceneObjectGroup)entity; - if (group.FromItemID == itemID) - { - m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); - sp.RemoveAttachment(group); - m_scene.DeleteSceneObject(group, false); + m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); + sp.RemoveAttachment(group); + m_scene.DeleteSceneObject(group, false); - // Prepare sog for storage - group.AttachedAvatar = UUID.Zero; - group.RootPart.SetParentLocalId(0); - group.IsAttachment = false; - group.AbsolutePosition = group.RootPart.AttachedPos; + // Prepare sog for storage + group.AttachedAvatar = UUID.Zero; + group.RootPart.SetParentLocalId(0); + group.IsAttachment = false; + group.AbsolutePosition = group.RootPart.AttachedPos; - UpdateKnownItem(sp, group, true); + UpdateKnownItem(sp, group, true); - return; - } + return; } } } From bfa6896678872a4e796ec4de22e83b6cead3ba17 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Jun 2012 23:31:23 +0100 Subject: [PATCH 4/9] Change AttachmentsModule.DetachSingleAttachmentToInv() to accept a SOG directly instead of an item ID to then shuffle through attachments, saving CPU busywork. Almost all callers already had the sog to hand. Still checking that it's really an attachment, but now by inspecting SOG.AttachedAvatar --- .../Avatar/Attachments/AttachmentsModule.cs | 78 ++++++++++--------- .../Tests/AttachmentsModuleTests.cs | 7 +- .../Interfaces/IAttachmentsModule.cs | 6 +- .../Framework/Interfaces/IScenePresence.cs | 4 + .../Shared/Api/Implementation/LSL_Api.cs | 15 ++-- 5 files changed, 58 insertions(+), 52 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e9f0488396..af30a8e68e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -302,10 +302,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // At the moment we can only deal with a single attachment if (attachments.Count != 0) { - UUID oldAttachmentItemID = attachments[0].FromItemID; - - if (oldAttachmentItemID != UUID.Zero) - DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID); + if (attachments[0].FromItemID != UUID.Zero) + DetachSingleAttachmentToInvInternal(sp, attachments[0]); else m_log.WarnFormat( "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", @@ -442,18 +440,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); } - public void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID) + public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) { lock (sp.AttachmentsSyncLock) { // Save avatar attachment information // m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); - bool changed = sp.Appearance.DetachAttachment(itemID); + if (so.AttachedAvatar != sp.UUID) + { + m_log.WarnFormat( + "[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}", + so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName); + + return; + } + + bool changed = sp.Appearance.DetachAttachment(so.FromItemID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); - DetachSingleAttachmentToInvInternal(sp, itemID); + DetachSingleAttachmentToInvInternal(sp, so); } } @@ -657,39 +664,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return newItem; } - // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. - // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? - private void DetachSingleAttachmentToInvInternal(IScenePresence sp, UUID itemID) + private void DetachSingleAttachmentToInvInternal(IScenePresence sp, SceneObjectGroup so) { // m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name); - if (itemID == UUID.Zero) // If this happened, someone made a mistake.... - return; + m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero); + sp.RemoveAttachment(so); + m_scene.DeleteSceneObject(so, false); - lock (sp.AttachmentsSyncLock) - { - List attachments = sp.GetAttachments(); + // Prepare sog for storage + so.AttachedAvatar = UUID.Zero; + so.RootPart.SetParentLocalId(0); + so.IsAttachment = false; + so.AbsolutePosition = so.RootPart.AttachedPos; - foreach (SceneObjectGroup group in attachments) - { - if (group.FromItemID == itemID) - { - m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); - sp.RemoveAttachment(group); - m_scene.DeleteSceneObject(group, false); - - // Prepare sog for storage - group.AttachedAvatar = UUID.Zero; - group.RootPart.SetParentLocalId(0); - group.IsAttachment = false; - group.AbsolutePosition = group.RootPart.AttachedPos; - - UpdateKnownItem(sp, group, true); - - return; - } - } - } + UpdateKnownItem(sp, so, true); } private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( @@ -897,8 +886,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); + if (sp != null && group != null) - DetachSingleAttachmentToInv(sp, group.FromItemID); + DetachSingleAttachmentToInv(sp, group); } private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient) @@ -908,7 +898,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp != null) - DetachSingleAttachmentToInv(sp, itemID); + { + lock (sp.AttachmentsSyncLock) + { + List attachments = sp.GetAttachments(); + + foreach (SceneObjectGroup group in attachments) + { + if (group.FromItemID == itemID) + { + DetachSingleAttachmentToInv(sp, group); + return; + } + } + } + } } private void Client_OnObjectDrop(uint soLocalId, IClientAPI remoteClient) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 65722fe379..b0c087fb56 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -227,9 +227,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - scene.AttachmentsModule.RezSingleAttachmentFromInventory( - sp, attItem.ID, (uint)AttachmentPoint.Chest); - scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID); + SceneObjectGroup so + = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory( + sp, attItem.ID, (uint)AttachmentPoint.Chest); + scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.False); diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 375d3345a2..ba35a41046 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -109,11 +109,11 @@ namespace OpenSim.Region.Framework.Interfaces void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID); /// - /// Detach the given item so that it remains in the user's inventory. + /// Detach the given attachment so that it remains in the user's inventory. /// /// /param> - /// - void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID); + /// The attachment to detach. + void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); /// /// Update the position of an attachment. diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs index 19a8236427..e6b926ce8c 100644 --- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs +++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs @@ -72,6 +72,10 @@ namespace OpenSim.Region.Framework.Interfaces /// List GetAttachments(uint attachmentPoint); + /// + /// Does this avatar have any attachments? + /// + /// bool HasAttachments(); // Don't use these methods directly. Instead, use the AttachmentsModule diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a8679e2cb1..12eb098033 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2990,15 +2990,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void DetachWrapper(object o) { - SceneObjectPart host = (SceneObjectPart)o; - - SceneObjectGroup grp = host.ParentGroup; - UUID itemID = grp.FromItemID; - ScenePresence presence = World.GetScenePresence(host.OwnerID); - - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); + if (World.AttachmentsModule != null) + { + SceneObjectPart host = (SceneObjectPart)o; + ScenePresence presence = World.GetScenePresence(host.OwnerID); + World.AttachmentsModule.DetachSingleAttachmentToInv(presence, host.ParentGroup); + } } public void llAttachToAvatar(int attachmentPoint) From f202c36106815949e56c58612770a00c65ab80a3 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 29 Jun 2012 00:03:22 +0100 Subject: [PATCH 5/9] Add IScene.Name for code clarity to replace the RegionInfo.RegionName used in many, many log messages. --- OpenSim/Framework/IScene.cs | 5 ++ .../ClientStack/Linden/UDP/Tests/MockScene.cs | 3 +- OpenSim/Region/Framework/Scenes/Scene.cs | 50 +++++++++---------- OpenSim/Region/Framework/Scenes/SceneBase.cs | 12 +++-- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index b2604f4a39..a9432c2df3 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -56,6 +56,11 @@ namespace OpenSim.Framework public interface IScene { + /// + /// The name of this scene. + /// + string Name { get; } + RegionInfo RegionInfo { get; } RegionStatus RegionStatus { get; set; } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs index d76927be9f..119a677f80 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs @@ -44,9 +44,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests } protected int m_objectNameCallsReceived; - public MockScene() + public MockScene() : base(new RegionInfo(1000, 1000, null, null)) { - m_regInfo = new RegionInfo(1000, 1000, null, null); m_regStatus = RegionStatus.Up; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d44911604a..c28979e391 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -614,8 +614,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService = sceneGridService; m_SimulationDataService = simDataService; m_EstateDataService = estateDataService; - m_regionHandle = m_regInfo.RegionHandle; - m_regionName = m_regInfo.RegionName; + m_regionHandle = RegionInfo.RegionHandle; m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; @@ -630,7 +629,7 @@ namespace OpenSim.Region.Framework.Scenes // resave. // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. - RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID); + RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { @@ -659,10 +658,10 @@ namespace OpenSim.Region.Framework.Scenes if (updatedTerrainTextures) rs.Save(); - m_regInfo.RegionSettings = rs; + RegionInfo.RegionSettings = rs; if (estateDataService != null) - m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); + RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); #endregion Region Settings @@ -828,7 +827,7 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; } - public Scene(RegionInfo regInfo) + public Scene(RegionInfo regInfo) : base(regInfo) { PhysicalPrims = true; CollidablePrims = true; @@ -855,7 +854,6 @@ namespace OpenSim.Region.Framework.Scenes WestBorders.Add(westBorder); BordersLocked = false; - m_regInfo = regInfo; m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); @@ -1199,8 +1197,8 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.Close(); - if (!GridService.DeregisterRegion(m_regInfo.RegionID)) - m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); + if (!GridService.DeregisterRegion(RegionInfo.RegionID)) + m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); // call the base class Close method. base.Close(); @@ -1720,14 +1718,14 @@ namespace OpenSim.Region.Framework.Scenes public void StoreWindlightProfile(RegionLightShareData wl) { - m_regInfo.WindlightSettings = wl; + RegionInfo.WindlightSettings = wl; SimulationDataService.StoreRegionWindlightSettings(wl); m_eventManager.TriggerOnSaveNewWindlightProfile(); } public void LoadWindlightProfile() { - m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID); + RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID); m_eventManager.TriggerOnSaveNewWindlightProfile(); } @@ -2218,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes ForceSceneObjectBackup(so); so.DetachFromBackup(); - SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID); + SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID); } // We need to keep track of this state in case this group is still queued for further backup. @@ -2553,7 +2551,7 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) + if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) { m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); @@ -3734,9 +3732,9 @@ namespace OpenSim.Region.Framework.Scenes } } - if (m_regInfo.EstateSettings != null) + if (RegionInfo.EstateSettings != null) { - if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) + if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) { m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); @@ -3768,7 +3766,7 @@ namespace OpenSim.Region.Framework.Scenes } bool groupAccess = false; - UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups; + UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups; if (estateGroups != null) { @@ -3786,8 +3784,8 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); } - if (!m_regInfo.EstateSettings.PublicAccess && - !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && + if (!RegionInfo.EstateSettings.PublicAccess && + !RegionInfo.EstateSettings.HasAccess(agent.AgentID) && !groupAccess) { m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", @@ -3860,7 +3858,7 @@ namespace OpenSim.Region.Framework.Scenes // if (loggingOffUser != null) // { // UUID localRegionSecret = UUID.Zero; -// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); +// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret); // // // Region Secret is used here in case a new sessionid overwrites an old one on the user server. // // Will update the user server in a few revisions to use it. @@ -4079,13 +4077,13 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence sp = GetScenePresence(remoteClient.AgentId); if (sp != null) { - uint regionX = m_regInfo.RegionLocX; - uint regionY = m_regInfo.RegionLocY; + uint regionX = RegionInfo.RegionLocX; + uint regionY = RegionInfo.RegionLocY; Utils.LongToUInts(regionHandle, out regionX, out regionY); - int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize; - int shifty = (int) regionY - (int) m_regInfo.RegionLocY * (int)Constants.RegionSize; + int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; + int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; position.X += shiftx; position.Y += shifty; @@ -4108,7 +4106,7 @@ namespace OpenSim.Region.Framework.Scenes if (!result) { - regionHandle = m_regInfo.RegionHandle; + regionHandle = RegionInfo.RegionHandle; } else { @@ -4614,7 +4612,7 @@ namespace OpenSim.Region.Framework.Scenes public void DeleteFromStorage(UUID uuid) { - SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); + SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); } public int GetHealth() @@ -5039,7 +5037,7 @@ namespace OpenSim.Region.Framework.Scenes IEstateDataService estateDataService = EstateDataService; if (estateDataService != null) { - m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); + RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); TriggerEstateSunUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 9c6b8842f9..f50fbfcdbf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -51,6 +51,8 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region Fields + + public string Name { get { return RegionInfo.RegionName; } } public IConfigSource Config { @@ -146,6 +148,11 @@ namespace OpenSim.Region.Framework.Scenes #endregion + public SceneBase(RegionInfo regInfo) + { + RegionInfo = regInfo; + } + #region Update Methods /// @@ -209,10 +216,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public virtual RegionInfo RegionInfo - { - get { return m_regInfo; } - } + public virtual RegionInfo RegionInfo { get; private set; } #region admin stuff From 0f6b7b6a41ef40e8798638b79c4c62f00556a093 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 29 Jun 2012 00:11:44 +0100 Subject: [PATCH 6/9] If a link points to a non-existing item in FetchInventory caps, then don't try to add it to the return data rather than suffering an exception later on --- .../WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 515637eac0..9a6ca8640a 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -301,7 +301,8 @@ namespace OpenSim.Capabilities.Handlers InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID)); - itemsToReturn.Insert(0, linkedItem); + if (linkedItem != null) + itemsToReturn.Insert(0, linkedItem); } } } From 1a7be7b00eaef0140f2dc13f3e14d8150c393b08 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 29 Jun 2012 00:36:50 +0100 Subject: [PATCH 7/9] Fix a regression where we stopped removing avatars from collision event reporting on logout, rather than stopping clearing their collision events. This occurred in b18c8c8 (Thu May 17 2012). This was a cause of very occasional race conditions and likely memory leakage as clients came and went from the region. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 54b69a2c73..f3b0630843 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1270,7 +1270,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override void UnSubscribeEvents() { - CollisionEventsThisFrame.Clear(); + _parent_scene.RemoveCollisionEventReporting(this); // Don't clear collision event reporting here. This is called directly from scene code and so can lead // to a race condition with the simulate loop From e420f815dc9be9c7fc93cb94c86517d97abbed86 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 29 Jun 2012 00:54:40 +0100 Subject: [PATCH 8/9] refactor: rename _collisionEventPrim to m_collisionEventActors and _collisionEventPrimChanges to m_collisionEventActorsChanges to reflect their actual contents. These dictionaries handle all actor types, not just physical prims. --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index c6ecc68ae9..79de99e89c 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -387,12 +387,12 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// A dictionary of actors that should receive collision events. /// - private readonly Dictionary _collisionEventPrim = new Dictionary(); + private readonly Dictionary m_collisionEventActors = new Dictionary(); /// /// A dictionary of collision event changes that are waiting to be processed. /// - private readonly Dictionary _collisionEventPrimChanges = new Dictionary(); + private readonly Dictionary m_collisionEventActorsChanges = new Dictionary(); /// /// Maps a unique geometry id (a memory location) to a physics actor name. @@ -1908,8 +1908,8 @@ namespace OpenSim.Region.Physics.OdePlugin { // m_log.DebugFormat("[PHYSICS]: Adding {0} {1} to collision event reporting", obj.SOPName, obj.LocalID); - lock (_collisionEventPrimChanges) - _collisionEventPrimChanges[obj.LocalID] = obj; + lock (m_collisionEventActorsChanges) + m_collisionEventActorsChanges[obj.LocalID] = obj; } /// @@ -1920,8 +1920,8 @@ namespace OpenSim.Region.Physics.OdePlugin { // m_log.DebugFormat("[PHYSICS]: Removing {0} {1} from collision event reporting", obj.SOPName, obj.LocalID); - lock (_collisionEventPrimChanges) - _collisionEventPrimChanges[obj.LocalID] = null; + lock (m_collisionEventActorsChanges) + m_collisionEventActorsChanges[obj.LocalID] = null; } #region Add/Remove Entities @@ -2930,17 +2930,17 @@ namespace OpenSim.Region.Physics.OdePlugin // We change _collisionEventPrimChanges to avoid locking _collisionEventPrim itself and causing potential // deadlock if the collision event tries to lock something else later on which is already locked by a // caller that is adding or removing the collision event. - lock (_collisionEventPrimChanges) + lock (m_collisionEventActorsChanges) { - foreach (KeyValuePair kvp in _collisionEventPrimChanges) + foreach (KeyValuePair kvp in m_collisionEventActorsChanges) { if (kvp.Value == null) - _collisionEventPrim.Remove(kvp.Key); + m_collisionEventActors.Remove(kvp.Key); else - _collisionEventPrim[kvp.Key] = kvp.Value; + m_collisionEventActors[kvp.Key] = kvp.Value; } - _collisionEventPrimChanges.Clear(); + m_collisionEventActorsChanges.Clear(); } if (SupportsNINJAJoints) @@ -3092,7 +3092,7 @@ namespace OpenSim.Region.Physics.OdePlugin tempTick = tempTick2; } - foreach (PhysicsActor obj in _collisionEventPrim.Values) + foreach (PhysicsActor obj in m_collisionEventActors.Values) { // m_log.DebugFormat("[PHYSICS]: Assessing {0} {1} for collision events", obj.SOPName, obj.LocalID); From 0229e90dcc579cee8fe3321a78f6d75b5d70486e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 29 Jun 2012 01:02:35 +0100 Subject: [PATCH 9/9] Move update of the final optional ODE total frame stat inside the OdeLock rather than outside to avoid a very occasional race condition with the stat collection thread --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 79de99e89c..32e81e2ea1 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -3227,10 +3227,10 @@ namespace OpenSim.Region.Physics.OdePlugin } tickCountFrameRun = Util.EnvironmentTickCount(); - } - if (CollectStats) - m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick); + if (CollectStats) + m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick); + } return fps; }