From 32c43bf59a3b9c3cb0b9eb1d52f664997e39a50d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 5 Apr 2010 19:37:02 +0100 Subject: [PATCH 01/23] Partially implement share with group option for object inventory items If serverside permissions are off then this works as expected. Previously, it was impossible for more than one person to edit such items even if permissions were off. If serverside permissions are on then this works as expected if the object was created by an avatar who had the required group active. However, if the group for the object is later set then the contained item is still not editable. This may be linked to a wider bug where the object is still not modifiable by the group anyway Resolve conflict in LLClientView --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 13 ++++++++----- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 + .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 4 +++- .../Framework/Scenes/SceneObjectPartInventory.cs | 10 +++++++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 724c8bc986..bd0c1461cc 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -657,8 +657,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ProcessSpecificPacketAsync(object state) { AsyncPacketProcess packetObject = (AsyncPacketProcess)state; - packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); - + packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); } #endregion Packet Handling @@ -7662,12 +7661,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask; newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask; newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask; + + // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something + // different //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned; newTaskItem.Type = updatetask.InventoryData.Type; newTaskItem.InvType = updatetask.InventoryData.InvType; newTaskItem.Flags = updatetask.InventoryData.Flags; //newTaskItem.SaleType=updatetask.InventoryData.SaleType; - //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;; + //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice; newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name); newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description); newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate; @@ -7675,7 +7677,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP newTaskItem, updatetask.UpdateData.LocalID); } } - } + } return true; } @@ -11590,6 +11592,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public PacketMethod method; public bool Async; } + public class AsyncPacketProcess { public bool result = false; @@ -11632,4 +11635,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(packet, ThrottleOutPacketType.Task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 42a748ff67..26d3372a63 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1222,6 +1222,7 @@ namespace OpenSim.Region.Framework.Scenes item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); } + // If we've found the item in the user's inventory or in the library if (item != null) { part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 71354b4eac..4034744c58 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -173,7 +173,9 @@ namespace OpenSim.Region.Framework.Scenes item.NextPermissions; taskItem.NextPermissions = item.NextPermissions; taskItem.CurrentPermissions |= 8; - } else { + } + else + { taskItem.BasePermissions = item.BasePermissions; taskItem.CurrentPermissions = item.CurrentPermissions; taskItem.CurrentPermissions |= 8; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 21ca1de6f9..d175695833 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -528,6 +528,7 @@ namespace OpenSim.Region.Framework.Scenes item.ParentID = m_part.UUID; item.ParentPartID = m_part.UUID; item.Name = name; + item.GroupID = m_part.GroupID; lock (m_items) { @@ -620,6 +621,12 @@ namespace OpenSim.Region.Framework.Scenes item.ParentID = m_part.UUID; item.ParentPartID = m_part.UUID; item.Flags = m_items[item.ItemID].Flags; + + // If group permissions have been set on, check that the groupID is up to date in case it has + // changed since permissions were last set. + if (item.GroupPermissions != (uint)PermissionMask.None) + item.GroupID = m_part.GroupID; + if (item.AssetID == UUID.Zero) { item.AssetID = m_items[item.ItemID].AssetID; @@ -771,6 +778,7 @@ namespace OpenSim.Region.Framework.Scenes uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; + uint groupMask = item.GroupPermissions; invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); @@ -780,7 +788,7 @@ namespace OpenSim.Region.Framework.Scenes invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); - invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); + invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); From 66a833796c6eb6c7db75fa001370b3ee7689b9e7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 5 Apr 2010 20:42:20 +0100 Subject: [PATCH 02/23] check group membership and powers with the groups module rather than just the client's active group id this resolves the earlier issue where notecards/scripts shared with group could only be edited if the user had that group active --- .../World/Permissions/PermissionsModule.cs | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index b55718614b..db900dff5b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -145,7 +145,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions private Dictionary GrantVB = new Dictionary(); private Dictionary GrantJS = new Dictionary(); private Dictionary GrantYP = new Dictionary(); - private IFriendsModule m_friendsModule = null; + private IFriendsModule m_friendsModule; + private IGroupsModule m_groupsModule; #endregion @@ -370,9 +371,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_friendsModule = m_scene.RequestModuleInterface(); if (m_friendsModule == null) - m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); - else - m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); + m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work"); + + m_groupsModule = m_scene.RequestModuleInterface(); + + if (m_groupsModule == null) + m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work"); } public void Close() @@ -407,14 +411,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions // with the powers requested (powers = 0 for no powers check) protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) { - ScenePresence sp = m_scene.GetScenePresence(userID); - if (sp != null) - { - IClientAPI client = sp.ControllingClient; + if (null == m_groupsModule) + return false; - return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && - ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); + GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); + + if (gmd != null) + { + if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) + return true; } + return false; } @@ -705,8 +712,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions permission = false; } +// m_log.DebugFormat( +// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", +// group.GroupID, +// m_scene.GetSceneObjectPart(objId).GroupMask, +// IsGroupMember(group.GroupID, currentUser, 0), +// currentUser); + // Group members should be able to edit group objects - if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0)) + if ((group.GroupID != UUID.Zero) + && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) + && IsGroupMember(group.GroupID, currentUser, 0)) { // Return immediately, so that the administrator can shares group objects return true; @@ -941,7 +957,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericObjectPermission(editorID, objectID, false); } From d6e1333810b41407378a534a720128b498e0aada Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 19 Apr 2010 21:02:36 +0100 Subject: [PATCH 03/23] If a transfer request is received for a task inventory item asset, then route the permissions request through the existing CanEditScript() and CanEditNotecard() methods. This implements the 'share with group' flag for notecards and scripts in prim inventory since the PermissionsModule checks group membership and permissions. Other than that, the code in PermissionsModule duplicates the checks in LLClientView so there should be no change other than allowing group members to edit embedded notecards and scripts. For all other asset types, the permission checking code in LLClientView continues to be used, pending refactoring of suitable permissions code This means that 'share with group' will not yet work for prim inventory items other than notecards and scripts --- .../ClientStack/LindenUDP/LLClientView.cs | 99 +++++++++++++++---- .../World/Permissions/PermissionsModule.cs | 17 ++-- 2 files changed, 91 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index bd0c1461cc..c9ef173db0 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7053,32 +7053,89 @@ namespace OpenSim.Region.ClientStack.LindenUDP taskID = new UUID(transfer.TransferInfo.Params, 48); UUID itemID = new UUID(transfer.TransferInfo.Params, 64); UUID requestID = new UUID(transfer.TransferInfo.Params, 80); + +// m_log.DebugFormat( +// "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}", +// requestID, itemID, taskID, Name); + if (!(((Scene)m_scene).Permissions.BypassPermissions())) { if (taskID != UUID.Zero) // Prim { SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); if (part == null) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist", + Name, requestID, itemID, taskID); return true; + } - if (part.OwnerID != AgentId) - return true; - - if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) - return true; - - TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); - if (ti == null) - return true; - - if (ti.OwnerID != AgentId) - return true; - - if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) - return true; - - if (ti.AssetID != requestID) + TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID); + if (tii == null) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist", + Name, requestID, itemID, taskID); return true; + } + + if (tii.Type == (int)AssetType.LSLText) + { + if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId)) + return true; + } + else if (tii.Type == (int)AssetType.Notecard) + { + if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId)) + return true; + } + else + { + // TODO: Change this code to allow items other than notecards and scripts to be successfully + // shared with group. In fact, all this permissions checking should move to an IPermissionsModule + if (part.OwnerID != AgentId) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}", + Name, requestID, itemID, taskID, part.OwnerID); + return true; + } + + if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set", + Name, requestID, itemID, taskID); + return true; + } + + if (tii.OwnerID != AgentId) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", + Name, requestID, itemID, taskID, tii.OwnerID); + return true; + } + + if (( + tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", + Name, requestID, itemID, taskID); + return true; + } + + if (tii.AssetID != requestID) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", + Name, requestID, itemID, taskID, tii.AssetID); + return true; + } + } } else // Agent { @@ -7114,7 +7171,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if (assetRequestItem.AssetID != requestID) + { + m_log.WarnFormat( + "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", + Name, requestID, itemID, assetRequestItem.AssetID); return true; + } } } } @@ -11310,8 +11372,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // } } - //check to see if asset is in local cache, if not we need to request it from asset server. - //m_log.Debug("asset request " + requestID); +// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index db900dff5b..a972ca6936 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1063,7 +1063,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) return false; - } else { + } + else + { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return false; } @@ -1079,7 +1081,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; if (!IsGroupMember(ti.GroupID, user, 0)) - return false; + return false; } // Require full perms @@ -1483,14 +1485,16 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (part.OwnerID != user) { if (part.GroupID == UUID.Zero) - return false; + return false; if (!IsGroupMember(part.GroupID, user, 0)) return false; if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) return false; - } else { + } + else + { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return false; } @@ -1806,7 +1810,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions // Is it correct to be less restrictive for lists of objects to be returned? } - private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { + private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) + { //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); switch (scriptType) { case 0: @@ -1840,4 +1845,4 @@ namespace OpenSim.Region.CoreModules.World.Permissions return(false); } } -} +} \ No newline at end of file From 50ddb20204e8eb513212fe80d80b1308280fd47f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 May 2010 21:35:17 +0100 Subject: [PATCH 04/23] commit code which stops full updates being fired multiple times when attachments cross standalone region boundaries lots of messy debug code here too which would need to be removed --- .../Interregion/LocalInterregionComms.cs | 2 +- .../Framework/Scenes/Scene.Inventory.cs | 5 +++ .../Framework/Scenes/Scene.PacketHandlers.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 43 ++++++++++++++++--- .../Scenes/SceneCommunicationService.cs | 2 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 34 ++++++++++++++- .../Framework/Scenes/SceneObjectGroup.cs | 15 +++++-- .../Framework/Scenes/SceneObjectPart.cs | 34 +++++++++++---- .../Region/Framework/Scenes/SceneViewer.cs | 8 +++- bin/OpenSim.exe.config | 2 +- 10 files changed, 123 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs index d68c683143..4abc2158f9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs @@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { if (s.RegionInfo.RegionHandle == regionHandle) { - //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); + m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); if (isLocalCall) { // We need to make a local copy of the object diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a2634f7bec..f556b35ac7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2449,6 +2449,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + m_log.DebugFormat("[SCENE INVENTORY]: {0} {1} IsAttachment={2}", att.Name, att.LocalId, att.IsAttachment); + Console.WriteLine("HERE X"); ScenePresence presence; if (TryGetAvatar(remoteClient.AgentId, out presence)) { @@ -2456,9 +2458,12 @@ namespace OpenSim.Region.Framework.Scenes InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); + Console.WriteLine("HERE Y"); if (m_AvatarFactory != null) m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + + Console.WriteLine("HERE Z"); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index ac04dc795b..d8e604ff9b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes { if (((SceneObjectGroup)ent).LocalId == primLocalID) { + m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name); ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e8c49786ca..f8ca0479ef 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1833,6 +1833,28 @@ namespace OpenSim.Region.Framework.Scenes return sceneObject; } + /// + /// Add an object into the scene that has come from storage + /// + /// + /// + /// + /// If true, changes to the object will be reflected in its persisted data + /// If false, the persisted data will not be changed even if the object in the scene is changed + /// + /// + /// If true, we won't persist this object until it changes + /// If false, we'll persist this object immediately + /// + /// + /// true if the object was added, false if an object with the same uuid was already in the scene + /// + public bool AddRestoredSceneObject( + SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) + { + return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); + } + /// /// Add an object into the scene that has come from storage /// @@ -1852,7 +1874,7 @@ namespace OpenSim.Region.Framework.Scenes public bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) { - return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted); + return AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true); } /// @@ -2465,7 +2487,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IncomingCreateObject(ISceneObject sog) { - //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); + m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); SceneObjectGroup newObject; try { @@ -2537,10 +2559,12 @@ namespace OpenSim.Region.Framework.Scenes if (sceneObject.IsAttachmentCheckFull()) // Attachment { + m_log.DebugFormat("[SCENE]: Adding attachment {0} {1}", sceneObject.Name, sceneObject.LocalId); + sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); sceneObject.RootPart.AddFlag(PrimFlags.Phantom); - AddRestoredSceneObject(sceneObject, false, false); + AddRestoredSceneObject(sceneObject, false, false, false); // Handle attachment special case SceneObjectPart RootPrim = sceneObject.RootPart; @@ -2548,6 +2572,8 @@ namespace OpenSim.Region.Framework.Scenes // Fix up attachment Parent Local ID ScenePresence sp = GetScenePresence(sceneObject.OwnerID); + Console.WriteLine("AAAA"); + //uint parentLocalID = 0; if (sp != null) { @@ -2566,20 +2592,25 @@ namespace OpenSim.Region.Framework.Scenes //grp.SetFromAssetID(grp.RootPart.LastOwnerID); m_log.DebugFormat( "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); - + + RootPrim.RemFlag(PrimFlags.TemporaryOnRez); AttachObject( sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); - RootPrim.RemFlag(PrimFlags.TemporaryOnRez); - grp.SendGroupFullUpdate(); + + //grp.SendGroupFullUpdate(); } else { RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.AddFlag(PrimFlags.TemporaryOnRez); } + + Console.WriteLine("BBBB"); } else { + m_log.DebugFormat("[SCENE]: Adding ordinary object {0} {1}", sceneObject.Name, sceneObject.LocalId); + AddRestoredSceneObject(sceneObject, true, false); if (!Permissions.CanObjectEntry(sceneObject.UUID, diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 2f6a0dbb98..50feb17cc4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1383,7 +1383,9 @@ namespace OpenSim.Region.Framework.Scenes // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); + Console.WriteLine("SCS 1"); agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true); + Console.WriteLine("SCS 2"); // m_scene.SendKillObject(m_localId); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 59a2f41218..fa3c5eb5f1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -216,11 +216,15 @@ namespace OpenSim.Region.Framework.Scenes /// If true, we won't persist this object until it changes /// If false, we'll persist this object immediately /// + /// + /// If true, we send updates to the client to tell it about this object + /// If false, we leave it up to the caller to do this + /// /// /// true if the object was added, false if an object with the same uuid was already in the scene /// protected internal bool AddRestoredSceneObject( - SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) + SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) { if (!alreadyPersisted) { @@ -228,8 +232,29 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.HasGroupChanged = true; } - return AddSceneObject(sceneObject, attachToBackup, true); + return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); } + +// /// +// /// Add an object into the scene that has come from storage +// /// +// /// +// /// +// /// If true, changes to the object will be reflected in its persisted data +// /// If false, the persisted data will not be changed even if the object in the scene is changed +// /// +// /// +// /// If true, we won't persist this object until it changes +// /// If false, we'll persist this object immediately +// /// +// /// +// /// true if the object was added, false if an object with the same uuid was already in the scene +// /// +// protected internal bool AddRestoredSceneObject( +// SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) +// { +// AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true); +// } /// /// Add a newly created object to the scene. This will both update the scene, and send information about the @@ -611,11 +636,13 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool AttachObject( IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) { + Console.WriteLine("HERE A"); SceneObjectGroup group = GetGroupByPrim(objectLocalID); if (group != null) { if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) { + Console.WriteLine("HERE -1"); // If the attachment point isn't the same as the one previously used // set it's offset position = 0 so that it appears on the attachment point // and not in a weird location somewhere unknown. @@ -654,9 +681,12 @@ namespace OpenSim.Region.Framework.Scenes itemId = group.GetFromItemID(); } + Console.WriteLine("HERE 0"); m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); + Console.WriteLine("HERE 1"); group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); + Console.WriteLine("HERE 2"); // In case it is later dropped again, don't let // it get cleaned up // diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 602b811fe9..ba3fde7d92 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1494,6 +1494,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendFullUpdateToClient(IClientAPI remoteClient) { + if (IsAttachment) + m_log.DebugFormat( + "[SOG]: Sending full update to client {0} for {1} {2}", remoteClient.Name, Name, LocalId); + SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); lock (m_parts) @@ -1513,8 +1517,9 @@ namespace OpenSim.Region.Framework.Scenes /// internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) { -// m_log.DebugFormat( -// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); + if (IsAttachment) + m_log.DebugFormat( + "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); if (m_rootPart.UUID == part.UUID) { @@ -1994,7 +1999,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); + if (IsAttachment) + m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); RootPart.AddFullUpdateToAvatar(presence); @@ -2026,7 +2032,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); + if (IsAttachment) + m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); checkAtTargets(); RootPart.ScheduleFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a85a4b3179..ffbb4274b1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1259,16 +1259,17 @@ namespace OpenSim.Region.Framework.Scenes /// Tell all scene presences that they should send updates for this part to their clients /// public void AddFullUpdateToAllAvatars() - { + { ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) - { - avatars[i].SceneViewer.QueuePartForUpdate(this); - } + AddFullUpdateToAvatar(avatars[i]); } public void AddFullUpdateToAvatar(ScenePresence presence) { + if (IsAttachment) + m_log.DebugFormat("AddFullUpdateToAllAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); + presence.SceneViewer.QueuePartForUpdate(this); } @@ -1287,13 +1288,14 @@ namespace OpenSim.Region.Framework.Scenes { ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) - { - avatars[i].SceneViewer.QueuePartForUpdate(this); - } + AddTerseUpdateToAvatar(avatars[i]); } public void AddTerseUpdateToAvatar(ScenePresence presence) { + if (IsAttachment) + m_log.DebugFormat("AddTerseUpdateToAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); + presence.SceneViewer.QueuePartForUpdate(this); } @@ -2727,7 +2729,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleFullUpdate() { -// m_log.DebugFormat("[SCENE OBJECT PART]: Scheduling full update for {0} {1}", Name, LocalId); + if (IsAttachment) + m_log.DebugFormat("[SOP]: Scheduling full update for {0} {1}", Name, LocalId); if (m_parentGroup != null) { @@ -2840,6 +2843,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) { + if (IsAttachment) + m_log.DebugFormat( + "[SCENE OBJECT PART]: Sending part full update to {0} for {1} {2}", remoteClient.Name, Name, LocalId); + m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); } @@ -2848,6 +2855,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendFullUpdateToAllClients() { + if (IsAttachment) + m_log.DebugFormat( + "[SCENE OBJECT PART]: Sending full update for {0} {1} for all clients", Name, LocalId); + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) { @@ -2859,6 +2870,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendFullUpdateToAllClientsExcept(UUID agentID) { + if (IsAttachment) + m_log.DebugFormat( + "[SCENE OBJECT PART]: Sending full update for {0} {1} to all clients except {2}", Name, LocalId, agentID); + ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) { @@ -2965,6 +2980,9 @@ namespace OpenSim.Region.Framework.Scenes { if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes { + if (IsAttachment) + m_log.DebugFormat("[SOP]: Sending scheduled full update for {0} {1}", Name, LocalId); + AddFullUpdateToAllAvatars(); ClearUpdateSchedule(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index e4296ef66c..6f2bef982e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using OpenMetaverse; using log4net; using OpenSim.Framework; @@ -39,6 +40,8 @@ namespace OpenSim.Region.Framework.Scenes { public class SceneViewer : ISceneViewer { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected ScenePresence m_presence; protected UpdateQueue m_partsUpdateQueue = new UpdateQueue(); protected Queue m_pendingObjects; @@ -60,6 +63,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void QueuePartForUpdate(SceneObjectPart part) { + if (part.IsAttachment) + m_log.DebugFormat("[SCENE VIEWER]: Queueing part {0} {1} for update", part.Name, part.LocalId); + lock (m_partsUpdateQueue) { m_partsUpdateQueue.Enqueue(part); @@ -134,7 +140,7 @@ namespace OpenSim.Region.Framework.Scenes } else if (update.LastTerseUpdateTime <= part.TimeStampTerse) { -// m_log.DebugFormat( +// m_log.DebugFormat(AddFullUpdateToAvatar // "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", // part.Name, part.UUID, part.TimeStampTerse); diff --git a/bin/OpenSim.exe.config b/bin/OpenSim.exe.config index 3c7adf5419..4e7ef51bd8 100755 --- a/bin/OpenSim.exe.config +++ b/bin/OpenSim.exe.config @@ -12,7 +12,7 @@ - + From 693b5d08381a7672b3ebeb693ee50a82e8e59125 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 7 Jun 2010 16:07:43 +0100 Subject: [PATCH 05/23] reapply fix for double sending of attachment update on standalone region crossing --- .../Interregion/LocalInterregionComms.cs | 2 +- .../Framework/Scenes/Scene.Inventory.cs | 8 ++--- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++--- .../Scenes/SceneCommunicationService.cs | 4 +-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 10 +++--- .../Framework/Scenes/SceneObjectGroup.cs | 20 +++++------ .../Framework/Scenes/SceneObjectPart.cs | 34 +++++++++---------- .../Region/Framework/Scenes/SceneViewer.cs | 6 ++-- 9 files changed, 48 insertions(+), 48 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs index 4abc2158f9..0730f8b3ee 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs @@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { if (s.RegionInfo.RegionHandle == regionHandle) { - m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); +// m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); if (isLocalCall) { // We need to make a local copy of the object diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f556b35ac7..a11b1f1c3c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2449,8 +2449,8 @@ namespace OpenSim.Region.Framework.Scenes return; } - m_log.DebugFormat("[SCENE INVENTORY]: {0} {1} IsAttachment={2}", att.Name, att.LocalId, att.IsAttachment); - Console.WriteLine("HERE X"); +// m_log.DebugFormat("[SCENE INVENTORY]: {0} {1} IsAttachment={2}", att.Name, att.LocalId, att.IsAttachment); +// Console.WriteLine("HERE X"); ScenePresence presence; if (TryGetAvatar(remoteClient.AgentId, out presence)) { @@ -2458,12 +2458,12 @@ namespace OpenSim.Region.Framework.Scenes InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); - Console.WriteLine("HERE Y"); +// Console.WriteLine("HERE Y"); if (m_AvatarFactory != null) m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); - Console.WriteLine("HERE Z"); +// Console.WriteLine("HERE Z"); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index d8e604ff9b..adc9496db0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Scenes { if (((SceneObjectGroup)ent).LocalId == primLocalID) { - m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name); +// m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name); ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f8ca0479ef..7089368ee4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2487,7 +2487,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IncomingCreateObject(ISceneObject sog) { - m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); +// m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); SceneObjectGroup newObject; try { @@ -2559,7 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes if (sceneObject.IsAttachmentCheckFull()) // Attachment { - m_log.DebugFormat("[SCENE]: Adding attachment {0} {1}", sceneObject.Name, sceneObject.LocalId); +// m_log.DebugFormat("[SCENE]: Adding attachment {0} {1}", sceneObject.Name, sceneObject.LocalId); sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); sceneObject.RootPart.AddFlag(PrimFlags.Phantom); @@ -2572,7 +2572,7 @@ namespace OpenSim.Region.Framework.Scenes // Fix up attachment Parent Local ID ScenePresence sp = GetScenePresence(sceneObject.OwnerID); - Console.WriteLine("AAAA"); +// Console.WriteLine("AAAA"); //uint parentLocalID = 0; if (sp != null) @@ -2605,11 +2605,11 @@ namespace OpenSim.Region.Framework.Scenes RootPrim.AddFlag(PrimFlags.TemporaryOnRez); } - Console.WriteLine("BBBB"); +// Console.WriteLine("BBBB"); } else { - m_log.DebugFormat("[SCENE]: Adding ordinary object {0} {1}", sceneObject.Name, sceneObject.LocalId); +// m_log.DebugFormat("[SCENE]: Adding ordinary object {0} {1}", sceneObject.Name, sceneObject.LocalId); AddRestoredSceneObject(sceneObject, true, false); diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 50feb17cc4..67fa13d680 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1383,9 +1383,9 @@ namespace OpenSim.Region.Framework.Scenes // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); - Console.WriteLine("SCS 1"); +// Console.WriteLine("SCS 1"); agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true); - Console.WriteLine("SCS 2"); +// Console.WriteLine("SCS 2"); // m_scene.SendKillObject(m_localId); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fa3c5eb5f1..bdab6966ca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -636,13 +636,13 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool AttachObject( IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) { - Console.WriteLine("HERE A"); +// Console.WriteLine("HERE A"); SceneObjectGroup group = GetGroupByPrim(objectLocalID); if (group != null) { if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) { - Console.WriteLine("HERE -1"); +// Console.WriteLine("HERE -1"); // If the attachment point isn't the same as the one previously used // set it's offset position = 0 so that it appears on the attachment point // and not in a weird location somewhere unknown. @@ -681,12 +681,12 @@ namespace OpenSim.Region.Framework.Scenes itemId = group.GetFromItemID(); } - Console.WriteLine("HERE 0"); +// Console.WriteLine("HERE 0"); m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); - Console.WriteLine("HERE 1"); +// Console.WriteLine("HERE 1"); group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); - Console.WriteLine("HERE 2"); +// Console.WriteLine("HERE 2"); // In case it is later dropped again, don't let // it get cleaned up // diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ba3fde7d92..451c6f9f70 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1494,9 +1494,9 @@ namespace OpenSim.Region.Framework.Scenes public void SendFullUpdateToClient(IClientAPI remoteClient) { - if (IsAttachment) - m_log.DebugFormat( - "[SOG]: Sending full update to client {0} for {1} {2}", remoteClient.Name, Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat( +// "[SOG]: Sending full update to client {0} for {1} {2}", remoteClient.Name, Name, LocalId); SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); @@ -1517,9 +1517,9 @@ namespace OpenSim.Region.Framework.Scenes /// internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) { - if (IsAttachment) - m_log.DebugFormat( - "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); +// if (IsAttachment) +// m_log.DebugFormat( +// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); if (m_rootPart.UUID == part.UUID) { @@ -1999,8 +1999,8 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { - if (IsAttachment) - m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); +// if (IsAttachment) +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); RootPart.AddFullUpdateToAvatar(presence); @@ -2032,8 +2032,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleGroupForFullUpdate() { - if (IsAttachment) - m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); +// if (IsAttachment) +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); checkAtTargets(); RootPart.ScheduleFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ffbb4274b1..33624a2941 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1267,8 +1267,8 @@ namespace OpenSim.Region.Framework.Scenes public void AddFullUpdateToAvatar(ScenePresence presence) { - if (IsAttachment) - m_log.DebugFormat("AddFullUpdateToAllAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat("AddFullUpdateToAllAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); presence.SceneViewer.QueuePartForUpdate(this); } @@ -1293,8 +1293,8 @@ namespace OpenSim.Region.Framework.Scenes public void AddTerseUpdateToAvatar(ScenePresence presence) { - if (IsAttachment) - m_log.DebugFormat("AddTerseUpdateToAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat("AddTerseUpdateToAvatar() {0} for {1} {2}", presence.Name, Name, LocalId); presence.SceneViewer.QueuePartForUpdate(this); } @@ -2729,8 +2729,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleFullUpdate() { - if (IsAttachment) - m_log.DebugFormat("[SOP]: Scheduling full update for {0} {1}", Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat("[SOP]: Scheduling full update for {0} {1}", Name, LocalId); if (m_parentGroup != null) { @@ -2843,9 +2843,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) { - if (IsAttachment) - m_log.DebugFormat( - "[SCENE OBJECT PART]: Sending part full update to {0} for {1} {2}", remoteClient.Name, Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Sending part full update to {0} for {1} {2}", remoteClient.Name, Name, LocalId); m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); } @@ -2855,9 +2855,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendFullUpdateToAllClients() { - if (IsAttachment) - m_log.DebugFormat( - "[SCENE OBJECT PART]: Sending full update for {0} {1} for all clients", Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Sending full update for {0} {1} for all clients", Name, LocalId); ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) @@ -2870,9 +2870,9 @@ namespace OpenSim.Region.Framework.Scenes public void SendFullUpdateToAllClientsExcept(UUID agentID) { - if (IsAttachment) - m_log.DebugFormat( - "[SCENE OBJECT PART]: Sending full update for {0} {1} to all clients except {2}", Name, LocalId, agentID); +// if (IsAttachment) +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Sending full update for {0} {1} to all clients except {2}", Name, LocalId, agentID); ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avatars.Length; i++) @@ -2980,8 +2980,8 @@ namespace OpenSim.Region.Framework.Scenes { if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes { - if (IsAttachment) - m_log.DebugFormat("[SOP]: Sending scheduled full update for {0} {1}", Name, LocalId); +// if (IsAttachment) +// m_log.DebugFormat("[SOP]: Sending scheduled full update for {0} {1}", Name, LocalId); AddFullUpdateToAllAvatars(); ClearUpdateSchedule(); diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 6f2bef982e..23663dd58a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -63,8 +63,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void QueuePartForUpdate(SceneObjectPart part) { - if (part.IsAttachment) - m_log.DebugFormat("[SCENE VIEWER]: Queueing part {0} {1} for update", part.Name, part.LocalId); +// if (part.IsAttachment) +// m_log.DebugFormat("[SCENE VIEWER]: Queueing part {0} {1} for update", part.Name, part.LocalId); lock (m_partsUpdateQueue) { From 912f0c7fde1d3ec159b9f9b61136a2ac64e7d9dd Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 7 Jun 2010 18:49:22 +0100 Subject: [PATCH 06/23] Stop some hud components disappearing on region crossings If viewers (or at least, Linden Viewer 1.23.5) receive child hud object updates before the root prim, then the children are not displayed. Updates were being queued in LLClientView in the right order (root first) but were being sent in a random order since they were all at the same prioritization This commit prioritizes the root prim of a hud to its highest level when queued. I'm not sure if the periodic reprioritization triggered via ScenePresence might reset this, but boosting priority appears to work so far. Also committed is a belt and braces mechanism in LLClientView to prevent child hud prim being sent out before their root, but since this doesn't appear to be needed it is currently commented out. --- .../ClientStack/LindenUDP/LLClientView.cs | 54 ++++++++++++++++--- .../Framework/Scenes/SceneObjectPart.cs | 31 +++++++++-- .../Region/Framework/Scenes/ScenePresence.cs | 4 +- bin/OpenSim.exe.config | 4 +- 4 files changed, 79 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 724c8bc986..37929f2374 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -365,6 +365,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected HashSet m_killRecord; +// protected HashSet m_attachmentsQueued; +// protected HashSet m_attachmentsSent; + private int m_moneyBalance; private int m_animationSequenceNumber = 1; private bool m_SendLogoutPacketWhenClosing = true; @@ -456,6 +459,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdates = new PriorityQueue(m_scene.Entities.Count); m_fullUpdateDataBlocksBuilder = new List(); m_killRecord = new HashSet(); +// m_attachmentsQueued = new HashSet(); +// m_attachmentsSent = new HashSet(); m_assetService = m_scene.RequestModuleInterface(); m_hyperAssets = m_scene.RequestModuleInterface(); @@ -3401,6 +3406,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP objupdate.ObjectData[0] = CreateAvatarUpdateBlock(data); OutPacket(objupdate, ThrottleOutPacketType.Task); + + // We need to record the avatar local id since the root prim of an attachment points to this. +// m_attachmentsSent.Add(data.AvatarLocalID); } /// @@ -3523,6 +3531,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; ObjectUpdatePacket.ObjectDataBlock objectData = CreatePrimUpdateBlock(data); + +// if (data.attachment) +// m_attachmentsQueued.Add(data.localID); lock (m_primFullUpdates.SyncRoot) m_primFullUpdates.Enqueue(data.priority, objectData, data.localID); @@ -3549,15 +3560,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP ObjectUpdatePacket.ObjectDataBlock block = m_primFullUpdates.Dequeue(); if (!m_killRecord.Contains(block.ID)) - { + { +// if (m_attachmentsQueued.Contains(block.ID)) +// { +// string text = Util.FieldToString(block.Text); +// if (text.IndexOf("\n") >= 0) +// text = text.Remove(text.IndexOf("\n")); +// +// if (m_attachmentsSent.Contains(block.ParentID)) +// { +// m_log.DebugFormat( +// "[CLIENT]: Sending full info about attached prim {0} text {1}", +// block.ID, text); +// +// m_fullUpdateDataBlocksBuilder.Add(block); +// +// m_attachmentsSent.Add(block.ID); +// } +// else +// { +// m_log.DebugFormat( +// "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet", +// block.ID, text, block.ParentID); +// +// lock (m_primFullUpdates.SyncRoot) +// m_primFullUpdates.Enqueue(double.MaxValue, block, block.ID); +// } +// } +// else +// { m_fullUpdateDataBlocksBuilder.Add(block); - -// string text = Util.FieldToString(outPacket.ObjectData[i].Text); -// if (text.IndexOf("\n") >= 0) -// text = text.Remove(text.IndexOf("\n")); -// m_log.DebugFormat( -// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", -// outPacket.ObjectData[i].ID, text, Name); +// } } // else // { @@ -4506,6 +4539,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SendPrimitiveData data) { +// if (data.attachment) +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Creating prim update block for {0}, parent {1}, priority {2}", +// data.localID, data.parentID, data.priority); + byte[] objectData = new byte[60]; data.pos.ToBytes(objectData, 0); data.vel.ToBytes(objectData, 12); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 33624a2941..479ee4d516 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2929,10 +2929,33 @@ namespace OpenSim.Region.Framework.Scenes //isattachment = ParentGroup.RootPart.IsAttachment; byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; - remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, - lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, - m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, - AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); + + double priority = ParentGroup.GetUpdatePriority(remoteClient); + if (IsRoot && IsAttachment) + { + if (double.MinValue == priority) + { + m_log.WarnFormat( + "[SOP]: Couldn't raise update priority of root part for attachment {0} {1} because priority is already highest value", + Name, LocalId); + } + else + { + priority = double.MinValue; + } + } + + remoteClient.SendPrimitiveToClient( + new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, + lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, + m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, + AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, priority)); + +// if (IsRoot && IsAttachment) +// { +// ScenePresence sp = ParentGroup.Scene.GetScenePresence(remoteClient.AgentId); +// remoteClient.ReprioritizeUpdates(StateUpdateTypes.PrimitiveFull, sp.UpdatePriority); +// } } /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 49736633d4..18f2fd29ec 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3871,8 +3871,10 @@ namespace OpenSim.Region.Framework.Scenes } } - private double UpdatePriority(UpdatePriorityData data) + internal double UpdatePriority(UpdatePriorityData data) { +// m_log.DebugFormat("[SCENE PRESENCE]: Reprioritizing updates to client {0} for {1}", Name, data.localID); + EntityBase entity; SceneObjectGroup group; diff --git a/bin/OpenSim.exe.config b/bin/OpenSim.exe.config index 4e7ef51bd8..aa2162e9fd 100755 --- a/bin/OpenSim.exe.config +++ b/bin/OpenSim.exe.config @@ -12,7 +12,9 @@ - + + + From 255e05beb594001af971228cf9434d1cc2a63dbd Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 7 Jun 2010 19:52:45 +0100 Subject: [PATCH 07/23] minor: remove some commented out code and return ScenePresence.UpdatePriority() to private --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 ------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 479ee4d516..19ff2886e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2950,12 +2950,6 @@ namespace OpenSim.Region.Framework.Scenes lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, priority)); - -// if (IsRoot && IsAttachment) -// { -// ScenePresence sp = ParentGroup.Scene.GetScenePresence(remoteClient.AgentId); -// remoteClient.ReprioritizeUpdates(StateUpdateTypes.PrimitiveFull, sp.UpdatePriority); -// } } /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 18f2fd29ec..51cdf1b8ee 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3871,7 +3871,7 @@ namespace OpenSim.Region.Framework.Scenes } } - internal double UpdatePriority(UpdatePriorityData data) + private double UpdatePriority(UpdatePriorityData data) { // m_log.DebugFormat("[SCENE PRESENCE]: Reprioritizing updates to client {0} for {1}", Name, data.localID); From 052445806911288b49c36065575556559fe4963e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 3 Mar 2010 17:50:05 +0000 Subject: [PATCH 08/23] remove references to OpenSim.Framework.Commuications.Tests.dll since all relevant test code has been obsoleted this allows the tests to pass on my local system --- .nant/local.include | 22 ------------------- .../ClientStack/LindenUDP/LLClientView.cs | 16 +++++++++++--- .../Region/Framework/Scenes/SceneManager.cs | 2 +- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/.nant/local.include b/.nant/local.include index 3db063b3b2..6f0a362612 100644 --- a/.nant/local.include +++ b/.nant/local.include @@ -95,11 +95,6 @@ - - - - - @@ -160,17 +155,6 @@ - - - - - - - - - - - - diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index ec238ef37e..58aa26a788 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -98,6 +98,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector { + /// + /// Debug packet level. At the moment, only 255 does anything (prints out all in and out packets). + /// + protected int m_debugPacketLevel = 0; + #region Events public event GenericMessage OnGenericMessage; @@ -490,6 +495,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SetDebugPacketLevel(int newDebug) { + m_debugPacketLevel = newDebug; } #region Client Methods @@ -11080,7 +11086,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); #endregion BinaryStats - m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); + OutPacket(packet, throttlePacketType, true); } /// @@ -11093,6 +11099,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// handles splitting manually protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) { + if (m_debugPacketLevel >= 255) + m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type); + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); } @@ -11164,10 +11173,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// OpenMetaverse.packet public void ProcessInPacket(Packet Pack) { -// m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack); + if (m_debugPacketLevel >= 255) + m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); if (!ProcessPacketMethod(Pack)) - m_log.Warn("[CLIENT]: unhandled packet " + Pack); + m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); PacketPool.Instance.ReturnPacket(Pack); } diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index c2e3370eb0..92c278e4a6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -422,7 +422,7 @@ namespace OpenSim.Region.Framework.Scenes if (!scenePresence.IsChildAgent) { - m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", + m_log.DebugFormat("Packet debug for {0} {1} set to {2}", scenePresence.Firstname, scenePresence.Lastname, newDebug); From 8b3b89ecf40ebe4e78ca77ccc5e14b2632829119 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 8 Jun 2010 20:31:39 +0100 Subject: [PATCH 09/23] backport xmlrpcgroups cache from master --- .../ClientStack/LindenUDP/LLClientView.cs | 4 +- .../World/Permissions/PermissionsModule.cs | 23 +-- .../Framework/Scenes/Scene.PacketHandlers.cs | 3 +- .../Framework/Scenes/SceneObjectGroup.cs | 6 +- .../XmlRpcGroupsServicesConnectorModule.cs | 139 ++++++++++++------ 5 files changed, 114 insertions(+), 61 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 58aa26a788..20e53fc92e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3517,8 +3517,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // if (text.IndexOf("\n") >= 0) // text = text.Remove(text.IndexOf("\n")); // m_log.DebugFormat( -// "[CLIENT]: Placing request to send full info about prim {0} text {1} to client {2}", -// data.localID, text, Name); +// "[CLIENT]: Queueing send full info about prim {0}, attachment {1}, text {2} to client {3}", +// data.localID, data.attachment, text, Name); if (data.priority == double.NaN) { diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index a972ca6936..53556ab48b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -411,18 +411,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions // with the powers requested (powers = 0 for no powers check) protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) { - if (null == m_groupsModule) - return false; - - GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); - - if (gmd != null) + //DateTime t1 = DateTime.Now; + bool result = false; + + if (null != m_groupsModule) { - if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) - return true; + GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); + + if (gmd != null) + { + if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) + result = true; + } } + + //m_log.DebugFormat("[PERMISSIONS]: Group member check took {0}", (DateTime.Now - t1).TotalMilliseconds); - return false; + return result; } /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index adc9496db0..869efd790b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -116,6 +116,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestPrim(uint primLocalID, IClientAPI remoteClient) { +// m_log.DebugFormat("[SCENE]: {0} requested full update for {1}", remoteClient.Name, primLocalID); + List EntityList = GetEntities(); foreach (EntityBase ent in EntityList) @@ -124,7 +126,6 @@ namespace OpenSim.Region.Framework.Scenes { if (((SceneObjectGroup)ent).LocalId == primLocalID) { -// m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name); ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); return; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 451c6f9f70..fe5e948f64 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1519,7 +1519,7 @@ namespace OpenSim.Region.Framework.Scenes { // if (IsAttachment) // m_log.DebugFormat( -// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); +// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); if (m_rootPart.UUID == part.UUID) { @@ -2033,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes public void ScheduleGroupForFullUpdate() { // if (IsAttachment) -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); +// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); checkAtTargets(); RootPart.ScheduleFullUpdate(); @@ -2072,7 +2072,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsDeleted) return; -// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); +// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, LocalId); RootPart.SendFullUpdateToAllClients(); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 861731c1d4..e64c9a761c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; +using System.Text; using Nwc.XmlRpc; @@ -42,6 +43,7 @@ using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { @@ -72,7 +74,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private bool m_debugEnabled = false; - + private ExpiringCache m_memoryCache; + private int m_cacheTimeout = 30; + // Used to track which agents are have dropped from a group chat session // Should be reset per agent, on logon // TODO: move this to Flotsam XmlRpc Service @@ -132,8 +136,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); - + m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); + if (m_cacheTimeout == 0) + { + m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled."); + } + else + { + m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout); + } + // If we got all the config options we need, lets start'er'up + m_memoryCache = new ExpiringCache(); m_connectorEnabled = true; } } @@ -921,61 +935,94 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups /// private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) { - string UserService; - UUID SessionID; - GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); - param.Add("RequestingAgentID", requestingAgentID.ToString()); - param.Add("RequestingAgentUserService", UserService); - param.Add("RequestingSessionID", SessionID.ToString()); - - - param.Add("ReadKey", m_groupReadKey); - param.Add("WriteKey", m_groupWriteKey); - - if (m_debugEnabled) - { - m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:"); - foreach (string key in param.Keys) - { - m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]); - } - } - - IList parameters = new ArrayList(); - parameters.Add(param); - - ConfigurableKeepAliveXmlRpcRequest req; - req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); - XmlRpcResponse resp = null; + string CacheKey = null; - try + // Only bother with the cache if it isn't disabled. + if (m_cacheTimeout > 0) { - resp = req.Send(m_groupsServerURI, 10000); + if (!function.StartsWith("groups.get")) + { + // Any and all updates cause the cache to clear + m_memoryCache.Clear(); + } + else + { + StringBuilder sb = new StringBuilder(requestingAgentID + function); + foreach (object key in param.Keys) + { + if (param[key] != null) + { + sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString()); + } + } + + CacheKey = sb.ToString(); + m_memoryCache.TryGetValue(CacheKey, out resp); + } } - catch (Exception e) + + if (resp == null) { + string UserService; + UUID SessionID; + GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); + param.Add("RequestingAgentID", requestingAgentID.ToString()); + param.Add("RequestingAgentUserService", UserService); + param.Add("RequestingSessionID", SessionID.ToString()); - - m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); - m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); - - if ((req != null) && (req.RequestResponse != null)) + + param.Add("ReadKey", m_groupReadKey); + param.Add("WriteKey", m_groupWriteKey); + + if (m_debugEnabled) { - foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) + m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:"); + foreach (string key in param.Keys) + { + m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]); + } + } + + IList parameters = new ArrayList(); + parameters.Add(param); + + ConfigurableKeepAliveXmlRpcRequest req; + req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); + + try { - m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); + resp = req.Send(m_groupsServerURI, 10000); + + if ((m_cacheTimeout > 0) && (CacheKey != null)) + { + m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); + } } - } - - foreach (string key in param.Keys) + catch (Exception e) { - m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); + + + m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); + m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); + + if ((req != null) && (req.RequestResponse != null)) + { + foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) + { + m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); + } + } + + foreach (string key in param.Keys) + { + m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); + } + + Hashtable respData = new Hashtable(); + respData.Add("error", e.ToString()); + return respData; } - - Hashtable respData = new Hashtable(); - respData.Add("error", e.ToString()); - return respData; } From 5f60eb136e274d94806adf6645c3ed3a69ed28e0 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 8 Jun 2010 21:12:01 +0100 Subject: [PATCH 10/23] Improve instructions for [Groups] setup in OpenSim.ini.example --- bin/OpenSim.ini.example | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 37c0192660..aeece9c462 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -1290,39 +1290,42 @@ [Groups] Enabled = false - ; This is the current groups stub in Region.CoreModules.Avatar.Groups + ; This is the current groups stub in Region.CoreModules.Avatar.Groups. All the other settings below only really + ; apply to the Flotsam/SimianGrid GroupsModule Module = Default - ; The PHP code for the server is available from the Flotsam project for you to deploy - ; to your own server. The Flotsam project is located at http://code.google.com/p/flotsam/ - ; + ; This module can use a PHP XmlRpc server from the Flotsam project at http://code.google.com/p/flotsam/ + ; or from the SimianGrid project at http://code.google.com/p/openmetaverse ;Module = GroupsModule ; Enable Group Notices - ;NoticesEnabled = true + ;NoticesEnabled = true ; This makes the Groups modules very chatty on the console. DebugEnabled = false ; Specify which messaging module to use for groups messaging and if it's enabled ;MessagingModule = GroupsMessagingModule - ;MessagingEnabled = true + ;MessagingEnabled = true - ; Service connector to Groups Service [Select One] ServicesConnectorModule + ; Service connectors to the Groups Service. Select one depending on whether you're using a Flotsam XmlRpc backend or a SimianGrid backend + + ; SimianGrid Service for Groups + ;ServicesConnectorModule = SimianGroupsServicesConnector + ;GroupsServerURI = http://mygridserver.com:82/Grid/ - ; XmlRpc Service Connector to the Flotsam XmlRpc Groups Service settings + ; Flotsam XmlRpc Service for Groups ;ServicesConnectorModule = XmlRpcGroupsServicesConnector ;GroupsServerURI = http://yourxmlrpcserver.com/xmlrpc.php - ; XmlRpc Service Settings - ;XmlRpcServiceReadKey = 1234 - ;XmlRpcServiceWriteKey = 1234 + ; XmlRpc Security settings. These must match those set on your backend groups service. + ;XmlRpcServiceReadKey = 1234 + ;XmlRpcServiceWriteKey = 1234 ; Disables HTTP Keep-Alive for XmlRpcGroupsServicesConnector HTTP Requests, ; this is a work around fora problem discovered on some Windows based region servers. ; Only disable keep alive if you see a large number (dozens) of the following Exceptions: ; System.Net.WebException: The request was aborted: The request was canceled. - ; ; XmlRpcDisableKeepAlive = false From 491d898db8303c829d1e43f5c63afa05d6f6a445 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jun 2010 03:51:43 +0100 Subject: [PATCH 11/23] If a script is deleted before it gets compiled, don't even bother to try compiling it --- .../Region/ScriptEngine/XEngine/XEngine.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 98e77c0b92..f702e65bbe 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -122,6 +122,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); IWorkItemResult m_CurrentCompile = null; + private Dictionary m_CompileDict = new Dictionary(); public string ScriptEngineName { @@ -492,6 +493,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine else { m_CompileQueue.Enqueue(parms); + lock (m_CompileDict) + { + m_CompileDict[itemID] = 0; + } if (m_CurrentCompile == null) { @@ -554,6 +559,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine bool postOnRez = (bool)p[4]; StateSource stateSource = (StateSource)p[5]; + lock(m_CompileDict) + { + if (!m_CompileDict.ContainsKey(itemID)) + return false; + m_CompileDict.Remove(itemID); + } + // Get the asset ID of the script, so we can check if we // already have it. @@ -794,6 +806,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void OnRemoveScript(uint localID, UUID itemID) { + // If it's not yet been compiled, make sure we don't try + lock (m_CompileDict) + { + if (m_CompileDict.ContainsKey(itemID)) + m_CompileDict.Remove(itemID); + } + lock (m_Scripts) { // Do we even have it? From 821b8a551700405059ae62c02ba1c6fd2ebf2a39 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 Jun 2010 18:43:02 +0100 Subject: [PATCH 12/23] remove SimianGrid Groups OpenSim.ini.example stuff that accidentally crept in through a cherry-pick --- bin/OpenSim.ini.example | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index aeece9c462..c1c56397db 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -1291,11 +1291,10 @@ Enabled = false ; This is the current groups stub in Region.CoreModules.Avatar.Groups. All the other settings below only really - ; apply to the Flotsam/SimianGrid GroupsModule + ; apply to the Flotsam GroupsModule Module = Default ; This module can use a PHP XmlRpc server from the Flotsam project at http://code.google.com/p/flotsam/ - ; or from the SimianGrid project at http://code.google.com/p/openmetaverse ;Module = GroupsModule ; Enable Group Notices @@ -1308,13 +1307,7 @@ ;MessagingModule = GroupsMessagingModule ;MessagingEnabled = true - ; Service connectors to the Groups Service. Select one depending on whether you're using a Flotsam XmlRpc backend or a SimianGrid backend - - ; SimianGrid Service for Groups - ;ServicesConnectorModule = SimianGroupsServicesConnector - ;GroupsServerURI = http://mygridserver.com:82/Grid/ - - ; Flotsam XmlRpc Service for Groups + ; Flotsam XmlRpc Service for Groups. Uncomment these settings and change accordingly if you are using this backend groups service ;ServicesConnectorModule = XmlRpcGroupsServicesConnector ;GroupsServerURI = http://yourxmlrpcserver.com/xmlrpc.php @@ -1410,4 +1403,4 @@ ; to use to send XMLRPC requests to that script ;XmlRpcRouterModule = "XmlRpcRouterModule" - ;XmlRpcPort = 20800 + oXmlRpcPort = 20800 From 85c20e149364dba6f171db1d2018c2149c6b102f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 Jun 2010 19:40:09 +0100 Subject: [PATCH 13/23] revert group membership checking to older code pending resolution of reported performance problems --- .../World/Permissions/PermissionsModule.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 53556ab48b..91ce36256b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -414,6 +414,16 @@ namespace OpenSim.Region.CoreModules.World.Permissions //DateTime t1 = DateTime.Now; bool result = false; + ScenePresence sp = m_scene.GetScenePresence(userID); + if (sp != null) + { + IClientAPI client = sp.ControllingClient; + + result = ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && + ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); + } + + /* if (null != m_groupsModule) { GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); @@ -424,6 +434,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions result = true; } } + */ //m_log.DebugFormat("[PERMISSIONS]: Group member check took {0}", (DateTime.Now - t1).TotalMilliseconds); From ae2454821628d847b0add20a4c593162baafde5b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 29 Jun 2010 18:54:31 +0100 Subject: [PATCH 14/23] stop exceptions in setting and getting state from propogating since they aren't fatal to operations this will hopefully stop "save oar" from failing if a script asset is corrupt --- .../Scenes/SceneObjectPartInventory.cs | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index d175695833..5ab7d20ba6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (IScriptModule e in engines) { if (e != null) - { + { ArrayList errors = e.GetScriptErrors(itemID); foreach (Object line in errors) ret.Add(line); @@ -359,14 +359,26 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; } + foreach (IScriptModule e in engines) { if (e != null) { - if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) - break; + // Stop an exception in setting saved state from propogating since this is not fatal. + try + { + if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) + break; + } + catch (Exception ex) + { + m_log.WarnFormat( + "[PRIM INVENTORY]: Could not set script state for old key {0}, new key {1} in prim {2} {3}. Exception {4}{5}", + oldID, newID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); + } } } + m_part.ParentGroup.m_savedScriptState.Remove(oldID); } } @@ -1028,12 +1040,23 @@ namespace OpenSim.Region.Framework.Scenes { if (e != null) { - string n = e.GetXMLState(item.ItemID); - if (n != String.Empty) + // Stop any exception from the script engine from propogating since setting state + // isn't essential. + try { - if (!ret.ContainsKey(item.ItemID)) - ret[item.ItemID] = n; - break; + string n = e.GetXMLState(item.ItemID); + if (n != String.Empty) + { + if (!ret.ContainsKey(item.ItemID)) + ret[item.ItemID] = n; + break; + } + } + catch (Exception ex) + { + m_log.WarnFormat( + "[PRIM INVENTORY]: Could not retrieve script state for item {0} {1} in prim {2} {3}. Exception {4}{5}", + item.Name, item.ItemID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); } } } From cabb70d90af48d6efd490c019fa7a899537c4187 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 29 Jun 2010 22:50:04 +0100 Subject: [PATCH 15/23] Revert "stop exceptions in setting and getting state from propogating since they aren't fatal to operations" This reverts commit ae2454821628d847b0add20a4c593162baafde5b. Reverted for now pending a fix to the underlying xengine problem instead. --- .../Scenes/SceneObjectPartInventory.cs | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5ab7d20ba6..d175695833 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (IScriptModule e in engines) { if (e != null) - { + { ArrayList errors = e.GetScriptErrors(itemID); foreach (Object line in errors) ret.Add(line); @@ -359,26 +359,14 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; } - foreach (IScriptModule e in engines) { if (e != null) { - // Stop an exception in setting saved state from propogating since this is not fatal. - try - { - if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) - break; - } - catch (Exception ex) - { - m_log.WarnFormat( - "[PRIM INVENTORY]: Could not set script state for old key {0}, new key {1} in prim {2} {3}. Exception {4}{5}", - oldID, newID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); - } + if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) + break; } } - m_part.ParentGroup.m_savedScriptState.Remove(oldID); } } @@ -1040,23 +1028,12 @@ namespace OpenSim.Region.Framework.Scenes { if (e != null) { - // Stop any exception from the script engine from propogating since setting state - // isn't essential. - try + string n = e.GetXMLState(item.ItemID); + if (n != String.Empty) { - string n = e.GetXMLState(item.ItemID); - if (n != String.Empty) - { - if (!ret.ContainsKey(item.ItemID)) - ret[item.ItemID] = n; - break; - } - } - catch (Exception ex) - { - m_log.WarnFormat( - "[PRIM INVENTORY]: Could not retrieve script state for item {0} {1} in prim {2} {3}. Exception {4}{5}", - item.Name, item.ItemID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); + if (!ret.ContainsKey(item.ItemID)) + ret[item.ItemID] = n; + break; } } } From 92edbd3e4745ea9007cf6ae42a38fbcd653cc848 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 30 Jun 2010 21:23:57 +0100 Subject: [PATCH 16/23] If an emergency pos is required for a new root agent, correctly preserve the z co-ord instead of accidentally resetting the incorrect x co-ord This is a one-liner. It has already been addressed in master and 0.7-post-fixes in a more extensive way --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 51cdf1b8ee..8a633b5f58 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -839,7 +839,7 @@ namespace OpenSim.Region.Framework.Scenes if (!(pos.Y < 0)) emergencyPos.Y = pos.Y; if (!(pos.Z < 0)) - emergencyPos.X = pos.X; + emergencyPos.Z = pos.Z; } if (pos.Y < 0) { @@ -857,7 +857,7 @@ namespace OpenSim.Region.Framework.Scenes emergencyPos.Y = pos.Y; //Leave as 128 } - + m_log.WarnFormat( "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", pos, Name, UUID, emergencyPos); From d743a221e88626bf8b7de8427c98e54df0f523d0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Jun 2010 21:25:39 +0100 Subject: [PATCH 17/23] Fix scripts in rezzed objects not starting (Mantis #4775) --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f702e65bbe..73ef570e30 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (stateSource == (int)StateSource.ScriptedRez) { + lock (m_CompileDict) + { + m_CompileDict[itemID] = 0; + } + DoOnRezScript(parms); } else From 0116b80795af199c8a68c6ba536c208ea82253d3 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 8 Jul 2010 10:14:02 -0700 Subject: [PATCH 18/23] fix a potential division by zero --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 1ea52c5c4e..326f3275a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -257,12 +257,17 @@ namespace OpenSim.Region.ScriptEngine.Shared public static double Mag(Vector3 v) { return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); - } - - public static Vector3 Norm(Vector3 vector) - { - double mag = Mag(vector); - return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); + } + + public static Vector3 Norm(Vector3 vector) + { + double mag = Mag(vector); + if (mag > 0.0) + { + double invMag = 1.0 / mag; + return vector * invMag; + } + return new Vector3(0, 0, 0); } #endregion From c7a2e1b2d40dff80bf7b65ee01b9e7916de0f5e4 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 8 Jul 2010 10:17:28 -0700 Subject: [PATCH 19/23] llVecNorm() now returns a zero-length vector when one is supplied as input. Addresses Mantis #4752 --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e4e087fb8a..eaaa9eb883 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -450,13 +450,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llVecNorm(LSL_Vector v) { - m_host.AddScriptLPS(1); - double mag = LSL_Vector.Mag(v); - LSL_Vector nor = new LSL_Vector(); - nor.x = v.x / mag; - nor.y = v.y / mag; - nor.z = v.z / mag; - return nor; + m_host.AddScriptLPS(1); + return LSL_Vector.Norm(v); } public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b) From a7f0af41ab157e09d84aca4ca9135a8aed0757d6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 13 Jul 2010 23:36:05 +0100 Subject: [PATCH 20/23] replace o with ; in oXmlRpcPort in OpenSim.ini.example Thanks to Nebadon for the spot --- bin/OpenSim.ini.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index c1c56397db..c296c359e5 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -1403,4 +1403,4 @@ ; to use to send XMLRPC requests to that script ;XmlRpcRouterModule = "XmlRpcRouterModule" - oXmlRpcPort = 20800 + ;XmlRpcPort = 20800 From 61f9b3c2cf1c39dd0d1c58eed7d322d29029c2c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Jul 2010 12:58:16 -0400 Subject: [PATCH 21/23] Bug in 0.6.9 sometimes restoring script state causes region console to crash due to unhandled file lock exception. Attempt to resolve by wrapping several instances of file create / read logic in using statements and added some error handling for locked file exceptions. If it is IDisposable, it must be disposed! The close statements are unnecessary but harmless so I have left those in. The end of the using block will close and dispose automagically. --- .../Region/ScriptEngine/XEngine/XEngine.cs | 123 ++++++++++++------ 1 file changed, 84 insertions(+), 39 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 73ef570e30..cc3722552b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1317,10 +1317,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { - FileStream tfs = File.Open(assemName + ".text", - FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); + using (FileStream tfs = File.Open(assemName + ".text", + FileMode.Open, FileAccess.Read)) + { + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + } assem = new System.Text.ASCIIEncoding().GetString(tdata); } @@ -1340,9 +1342,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { - FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); + using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) + { + fs.Read(data, 0, data.Length); + fs.Close(); + } assem = System.Convert.ToBase64String(data); } @@ -1358,13 +1362,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (File.Exists(fn + ".map")) { - FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); - StreamReader msr = new StreamReader(mfs); - - map = msr.ReadToEnd(); - - msr.Close(); - mfs.Close(); + using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read)) + { + using (StreamReader msr = new StreamReader(mfs)) + { + map = msr.ReadToEnd(); + msr.Close(); + } + mfs.Close(); + } } XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); @@ -1452,30 +1458,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine { Byte[] filedata = Convert.FromBase64String(base64); - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - - fs = File.Create(path + ".text"); - StreamWriter sw = new StreamWriter(fs); - - sw.Write(base64); - - sw.Close(); - fs.Close(); + try + { + using (FileStream fs = File.Create(path)) + { + fs.Write(filedata, 0, filedata.Length); + fs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + } + try + { + using (FileStream fs = File.Create(path + ".text")) + { + using (StreamWriter sw = new StreamWriter(fs)) + { + sw.Write(base64); + sw.Close(); + } + fs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + } } } string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); statepath = Path.Combine(statepath, itemID.ToString() + ".state"); - FileStream sfs = File.Create(statepath); - StreamWriter ssw = new StreamWriter(sfs); - - ssw.Write(stateE.OuterXml); - - ssw.Close(); - sfs.Close(); + try + { + using (FileStream sfs = File.Create(statepath)) + { + using (StreamWriter ssw = new StreamWriter(sfs)) + { + ssw.Write(stateE.OuterXml); + ssw.Close(); + } + sfs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + } XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); if (mapL.Count > 0) @@ -1485,13 +1520,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); - FileStream mfs = File.Create(mappath); - StreamWriter msw = new StreamWriter(mfs); - - msw.Write(mapE.InnerText); - - msw.Close(); - mfs.Close(); + try + { + using (FileStream mfs = File.Create(mappath)) + { + using (StreamWriter msw = new StreamWriter(mfs)) + { + msw.Write(mapE.InnerText); + msw.Close(); + } + mfs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + } } return true; From 4ae04dd0a8de4d3597ef96d951f5573fedc4e847 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 17 Jul 2010 01:00:23 +0100 Subject: [PATCH 22/23] extend exception catching for DoCreateChildAgentCall() from just WebException to Exception on feedback from Chris Hart. See http://opensimulator.org/mantis/view.php?id=4810 --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index ee7dec8837..a5d4ce5634 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -164,9 +164,9 @@ namespace OpenSim.Framework.Communications.Clients } } } - catch (WebException ex) + catch (Exception ex) { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); + m_log.DebugFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); // ignore, really } finally @@ -176,7 +176,6 @@ namespace OpenSim.Framework.Communications.Clients } return true; - } public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) From 95d9c773d94573026907d112a7ce82cf362bdd61 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 17 Jul 2010 01:18:43 +0100 Subject: [PATCH 23/23] Stop occasional permanently high 100% utilization when the server is started with many scripts See http://opensimulator.org/mantis/view.php?id=4799 for more details This is the equivalent patch that was applied to master 3.5 weeks ago, seemingly without bad consequences Thanks Snoopy! --- .../Scenes/SceneObjectPartInventory.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index d175695833..256e3b01f8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -31,6 +31,7 @@ using System.IO; using System.Collections.Generic; using System.Collections; using System.Reflection; +using System.Threading; using OpenMetaverse; using log4net; using OpenSim.Framework; @@ -201,6 +202,7 @@ namespace OpenSim.Region.Framework.Scenes if ((int)InventoryType.LSL == item.InvType) { CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); + Thread.Sleep(10); // workaround for Mono cpu utilization > 100% bug } } } @@ -258,7 +260,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.InfoFormat( // "[PRIM INVENTORY]: " + // "Starting script {0}, {1} in prim {2}, {3}", - // item.Name, item.ItemID, Name, UUID); + // item.Name, item.ItemID, m_part.Name, m_part.UUID); if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) return; @@ -296,20 +298,20 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (m_part.ParentGroup.m_savedScriptState != null) - RestoreSavedScriptState(item.OldItemID, item.ItemID); - lock (m_items) { + if (m_part.ParentGroup.m_savedScriptState != null) + RestoreSavedScriptState(item.OldItemID, item.ItemID); + m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; + + string script = Utils.BytesToString(asset.Data); + m_part.ParentGroup.Scene.EventManager.TriggerRezScript( + m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); + m_part.ParentGroup.AddActiveScriptCount(1); + m_part.ScheduleFullUpdate(); } - - string script = Utils.BytesToString(asset.Data); - m_part.ParentGroup.Scene.EventManager.TriggerRezScript( - m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); - m_part.ParentGroup.AddActiveScriptCount(1); - m_part.ScheduleFullUpdate(); } } );