From 9ecad5041944ad51a815972ace5366430973503c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Apr 2010 19:37:02 +0100 Subject: 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 --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 15 +++++++++------ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 + .../Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 4 +++- .../Region/Framework/Scenes/SceneObjectPartInventory.cs | 10 +++++++++- 4 files changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 25f6ef0..7ccdd58 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -669,8 +669,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 @@ -7683,12 +7682,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; @@ -7696,7 +7698,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP newTaskItem, updatetask.UpdateData.LocalID); } } - } + } return true; } @@ -11088,7 +11090,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_debugPacketLevel >= 255) m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); - + if (!ProcessPacketMethod(Pack)) m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); @@ -11615,6 +11617,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public PacketMethod method; public bool Async; } + public class AsyncPacketProcess { public bool result = false; @@ -11692,4 +11695,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(dialog, 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 31c0be1..3b7f38e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1160,6 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes item = LibraryService.LibraryRootFolder.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 71354b4..4034744 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 77bf6fe..2e13f90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -527,6 +527,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) { @@ -619,6 +620,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; @@ -770,6 +777,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()); @@ -779,7 +787,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)); -- cgit v1.1 From 1be19c7f42e3f47a89385f8a6fe18b5150e25249 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Apr 2010 19:46:43 +0100 Subject: log exceptions that end up at the top of a asynchronous viewer packet method call rather than swallowing them --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7ccdd58..516c23b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -641,7 +641,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (pprocessor.Async) { object obj = new AsyncPacketProcess(this, pprocessor.method, packet); - Util.FireAndForget(ProcessSpecificPacketAsync,obj); + Util.FireAndForget(ProcessSpecificPacketAsync, obj); result = true; } else @@ -669,7 +669,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ProcessSpecificPacketAsync(object state) { AsyncPacketProcess packetObject = (AsyncPacketProcess)state; - packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); + + try + { + packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); + } + catch (Exception e) + { + // Make sure that we see any exception caused by the asynchronous operation. + m_log.Error( + string.Format("[LLCLIENTVIEW]: Caught exception while processing {0}", packetObject.Pack), e); + } } #endregion Packet Handling @@ -11695,4 +11705,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(dialog, ThrottleOutPacketType.Task); } } -} \ No newline at end of file +} -- cgit v1.1 From 48d2e8309a4b16843687a37b5458d00535e139d8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Apr 2010 20:42:20 +0100 Subject: 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(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 0f830e1..d940564 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -162,7 +162,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 @@ -386,9 +387,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() @@ -423,14 +427,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; + + GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); - return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && - ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); + if (gmd != null) + { + if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) + return true; } + return false; } @@ -721,8 +728,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; @@ -957,7 +973,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericObjectPermission(editorID, objectID, false); } -- cgit v1.1 From 80346ad2e246a363dcf4c9a2819b52b1d7a0739c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Apr 2010 19:56:03 -0700 Subject: * May fix mantis #4603. * My local git wants to commit the groups files for line endings, I'm gonna let it do it. --- .../Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 128 +++++++++--------- .../Avatar/XmlRpcGroups/GroupsModule.cs | 6 +- .../XmlRpcGroups/IGroupsServicesConnector.cs | 12 +- .../SimianGroupsServicesConnectorModule.cs | 104 +++++++-------- .../XmlRpcGroupsServicesConnectorModule.cs | 144 ++++++++++----------- 5 files changed, 197 insertions(+), 197 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 17a5349..185d44d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -49,9 +49,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private List m_sceneList = new List(); - private IMessageTransferModule m_msgTransferModule = null; - - private IGroupsServicesConnector m_groupData = null; + private IMessageTransferModule m_msgTransferModule = null; + + private IGroupsServicesConnector m_groupData = null; // Config Options private bool m_groupMessagingEnabled = false; @@ -108,13 +108,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (!m_groupMessagingEnabled) return; - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - + if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + m_groupData = scene.RequestModuleInterface(); - // No groups module, no groups messaging + // No groups module, no groups messaging if (m_groupData == null) - { + { m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled."); Close(); m_groupMessagingEnabled = false; @@ -190,9 +190,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups #endregion - /// - /// Not really needed, but does confirm that the group exists. - /// + /// + /// Not really needed, but does confirm that the group exists. + /// public bool StartGroupChatSession(UUID agentID, UUID groupID) { if (m_debugEnabled) @@ -201,7 +201,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); if (groupInfo != null) - { + { return true; } else @@ -213,11 +213,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups public void SendMessageToGroup(GridInstantMessage im, UUID groupID) { if (m_debugEnabled) - m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - - + m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + + foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID)) - { + { if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) { // Don't deliver messages to people who have dropped this session @@ -226,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } // Copy Message - GridInstantMessage msg = new GridInstantMessage(); + GridInstantMessage msg = new GridInstantMessage(); msg.imSessionID = groupID.Guid; msg.fromAgentName = im.fromAgentName; msg.message = im.message; @@ -259,13 +259,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } } - #region SimGridEventHandlers - - void OnClientLogin(IClientAPI client) - { + #region SimGridEventHandlers + + void OnClientLogin(IClientAPI client) + { if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); - - + + } private void OnNewClient(IClientAPI client) @@ -303,28 +303,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void ProcessMessageFromGroupSession(GridInstantMessage msg) { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); - - UUID AgentID = new UUID(msg.fromAgentID); + if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); + + UUID AgentID = new UUID(msg.fromAgentID); UUID GroupID = new UUID(msg.imSessionID); switch (msg.dialog) { - case (byte)InstantMessageDialog.SessionAdd: + case (byte)InstantMessageDialog.SessionAdd: m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); break; - case (byte)InstantMessageDialog.SessionDrop: + case (byte)InstantMessageDialog.SessionDrop: m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID); break; - case (byte)InstantMessageDialog.SessionSend: - if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) + case (byte)InstantMessageDialog.SessionSend: + if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID) ) { // Agent not in session and hasn't dropped from session - // Add them to the session for now, and Invite them + // Add them to the session for now, and Invite them m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); UUID toAgentID = new UUID(msg.toAgentID); @@ -336,10 +336,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); - // Force? open the group session dialog??? + // Force? open the group session dialog??? // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); IEventQueue eq = activeClient.Scene.RequestModuleInterface(); - eq.ChatterboxInvitation( + eq.ChatterboxInvitation( GroupID , groupInfo.GroupName , new UUID(msg.fromAgentID) @@ -357,7 +357,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups , Utils.StringToBytes(groupInfo.GroupName) ); - eq.ChatterBoxSessionAgentListUpdates( + eq.ChatterBoxSessionAgentListUpdates( new UUID(GroupID) , new UUID(msg.fromAgentID) , new UUID(msg.toAgentID) @@ -367,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups ); } } - } + } else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) { // User hasn't dropped, so they're in the session, @@ -394,8 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups #endregion - - #region ClientEvents + + #region ClientEvents private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) { if (m_debugEnabled) @@ -407,23 +407,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Start group IM session if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) - { - if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); - - UUID GroupID = new UUID(im.imSessionID); - UUID AgentID = new UUID(im.fromAgentID); - + { + if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); + + UUID GroupID = new UUID(im.imSessionID); + UUID AgentID = new UUID(im.fromAgentID); + GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); if (groupInfo != null) - { + { m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID); IEventQueue queue = remoteClient.Scene.RequestModuleInterface(); - queue.ChatterBoxSessionAgentListUpdates( - GroupID + queue.ChatterBoxSessionAgentListUpdates( + GroupID , AgentID , new UUID(im.toAgentID) , false //canVoiceChat @@ -435,16 +435,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Send a message from locally connected client to a group if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) - { - UUID GroupID = new UUID(im.imSessionID); - UUID AgentID = new UUID(im.fromAgentID); + { + UUID GroupID = new UUID(im.imSessionID); + UUID AgentID = new UUID(im.fromAgentID); if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString()); - //If this agent is sending a message, then they want to be in the session - m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); - + //If this agent is sending a message, then they want to be in the session + m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); + SendMessageToGroup(im, GroupID); } } @@ -501,7 +501,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups /// Try to find an active IClientAPI reference for agentID giving preference to root connections /// private IClientAPI GetActiveClient(UUID agentID) - { + { if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); IClientAPI child = null; @@ -514,26 +514,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { ScenePresence user = (ScenePresence)scene.Entities[agentID]; if (!user.IsChildAgent) - { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); + { + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); return user.ControllingClient; } else - { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); + { + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); child = user.ControllingClient; } } } - // If we didn't find a root, then just return whichever child we found, or null if none - if (child == null) - { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); - } - else - { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); + // If we didn't find a root, then just return whichever child we found, or null if none + if (child == null) + { + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); + } + else + { + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); } return child; } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index e5dab93..56c0d98 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -175,13 +175,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; + scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; // The InstantMessageModule itself doesn't do this, // so lets see if things explode if we don't do it // scene.EventManager.OnClientClosed += OnClientClosed; - } - + } + public void RemoveRegion(Scene scene) { if (!m_groupsEnabled) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs index 54ffc81..a046e09 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs @@ -70,12 +70,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); - List GetGroupNotices(UUID RequestingAgentID, UUID GroupID); - - void ResetAgentGroupChatSessions(UUID agentID); - bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID); - bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID); - void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID); + List GetGroupNotices(UUID RequestingAgentID, UUID GroupID); + + void ResetAgentGroupChatSessions(UUID agentID); + bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID); + bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID); + void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID); void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID); } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 4867c01..669373f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs @@ -203,12 +203,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } - m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); - + m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); + m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); if ((m_groupsServerURI == null) || (m_groupsServerURI == string.Empty)) - { + { m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); m_connectorEnabled = false; return; @@ -1000,53 +1000,53 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); } - #endregion - - #region GroupSessionTracking - - public void ResetAgentGroupChatSessions(UUID agentID) - { - Dictionary agentSessions; - - if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) - { - foreach (string GroupID in agentSessions.Keys) - { - SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); - } - } - - if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) - { - foreach (string GroupID in agentSessions.Keys) - { - SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); - } - } - } - - public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) - { - OSDMap session; - return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); - } - - public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) - { - SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); - } - - public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); - } - - public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - OSDMap session; - return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); - } - + #endregion + + #region GroupSessionTracking + + public void ResetAgentGroupChatSessions(UUID agentID) + { + Dictionary agentSessions; + + if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) + { + foreach (string GroupID in agentSessions.Keys) + { + SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); + } + } + + if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) + { + foreach (string GroupID in agentSessions.Keys) + { + SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); + } + } + } + + public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) + { + OSDMap session; + return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); + } + + public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) + { + SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); + } + + public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) + { + SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); + } + + public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) + { + OSDMap session; + return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); + } + #endregion private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) @@ -1321,8 +1321,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return false; } } - #endregion - + #endregion + } } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 8e7aa68..523dfbe 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs @@ -68,14 +68,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private string m_groupReadKey = string.Empty; private string m_groupWriteKey = string.Empty; - private IUserAccountService m_accountService = null; - - // 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 - // SessionID, List - private Dictionary> m_groupsAgentsDroppedFromChatSession = new Dictionary>(); - private Dictionary> m_groupsAgentsInvitedToChatSession = new Dictionary>(); + private IUserAccountService m_accountService = null; + + // 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 + // SessionID, List + private Dictionary> m_groupsAgentsDroppedFromChatSession = new Dictionary>(); + private Dictionary> m_groupsAgentsInvitedToChatSession = new Dictionary>(); #region IRegionModuleBase Members @@ -111,12 +111,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } - m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); - + m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); + m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); if ((m_groupsServerURI == null) || (m_groupsServerURI == string.Empty)) - { + { m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); m_connectorEnabled = false; return; @@ -766,67 +766,67 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups - #endregion - - #region GroupSessionTracking - - public void ResetAgentGroupChatSessions(UUID agentID) - { - foreach (List agentList in m_groupsAgentsDroppedFromChatSession.Values) - { - agentList.Remove(agentID); - } - } - - public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - // If we're tracking this group, and we can find them in the tracking, then they've been invited - return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID) - && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID); - } - - public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) - { - // If we're tracking drops for this group, - // and we find them, well... then they've dropped - return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID) - && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID); - } - - public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) - { - if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) - { - // If not in dropped list, add - if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) - { - m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); - } - } - } - - public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - // Add Session Status if it doesn't exist for this session - CreateGroupChatSessionTracking(groupID); - - // If nessesary, remove from dropped list - if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) - { - m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); - } - } - - private void CreateGroupChatSessionTracking(UUID groupID) - { - if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) - { - m_groupsAgentsDroppedFromChatSession.Add(groupID, new List()); - m_groupsAgentsInvitedToChatSession.Add(groupID, new List()); - } - - } - #endregion + #endregion + + #region GroupSessionTracking + + public void ResetAgentGroupChatSessions(UUID agentID) + { + foreach (List agentList in m_groupsAgentsDroppedFromChatSession.Values) + { + agentList.Remove(agentID); + } + } + + public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) + { + // If we're tracking this group, and we can find them in the tracking, then they've been invited + return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID) + && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID); + } + + public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) + { + // If we're tracking drops for this group, + // and we find them, well... then they've dropped + return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID) + && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID); + } + + public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) + { + if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) + { + // If not in dropped list, add + if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) + { + m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); + } + } + } + + public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) + { + // Add Session Status if it doesn't exist for this session + CreateGroupChatSessionTracking(groupID); + + // If nessesary, remove from dropped list + if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) + { + m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); + } + } + + private void CreateGroupChatSessionTracking(UUID groupID) + { + if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) + { + m_groupsAgentsDroppedFromChatSession.Add(groupID, new List()); + m_groupsAgentsInvitedToChatSession.Add(groupID, new List()); + } + + } + #endregion #region XmlRpcHashtableMarshalling private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) -- cgit v1.1 From 3f6c4c150e3910e79ee3dc94f9304c16265512c0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 8 Apr 2010 12:31:44 -0700 Subject: * Adds IAssetService.GetCached() to allow asset fetching from the local cache only * Adds GetTextureModule that implements the "GetTexture" capability, aka HTTP texture fetching. This is a significantly optimized path that does not require any server-side JPEG2000 decoding, texture priority queue, or UDP file transfer * Sanity check for null reference in LLClientView.RefreshGroupMembership() --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 7 +- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 5 + .../CoreModules/Avatar/Assets/GetTextureModule.cs | 220 +++++++++++++++++++++ .../ServiceConnectorsOut/Asset/HGAssetBroker.cs | 8 + .../Asset/LocalAssetServiceConnector.cs | 8 + 5 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 516c23b..51ab281 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -11302,9 +11302,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_groupPowers.Clear(); - for (int i = 0; i < GroupMembership.Length; i++) + if (GroupMembership != null) { - m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + for (int i = 0; i < GroupMembership.Length; i++) + { + m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + } } } } diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 37cdaae..9eaa758 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -406,6 +406,11 @@ namespace Flotsam.RegionModules.AssetCache return asset; } + public AssetBase GetCached(string id) + { + return Get(id); + } + public void Expire(string id) { if (m_LogLevel >= 2) diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs new file mode 100644 index 0000000..53d2cef --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs @@ -0,0 +1,220 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.IO; +using System.Web; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; + +namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps +{ + #region Stream Handler + + public delegate byte[] StreamHandlerCallback(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse); + + public class StreamHandler : BaseStreamHandler + { + StreamHandlerCallback m_callback; + + public StreamHandler(string httpMethod, string path, StreamHandlerCallback callback) + : base(httpMethod, path) + { + m_callback = callback; + } + + public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return m_callback(path, request, httpRequest, httpResponse); + } + } + + #endregion Stream Handler + + public class GetTextureModule : IRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + private IAssetService m_assetService; + + #region IRegionModule Members + + public void Initialise(Scene pScene, IConfigSource pSource) + { + m_scene = pScene; + } + + public void PostInitialise() + { + m_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + public void Close() { } + + public string Name { get { return "GetTextureModule"; } } + public bool IsSharedModule { get { return false; } } + + public void RegisterCaps(UUID agentID, Caps caps) + { + UUID capID = UUID.Random(); + + m_log.Info("[GETTEXTURE]: /CAPS/" + capID); + caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); + } + + #endregion + + private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + // TODO: Change this to a config option + const string REDIRECT_URL = null; + + // Try to parse the texture ID from the request URL + NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); + string textureStr = query.GetOne("texture_id"); + + if (m_assetService == null) + { + m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service"); + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; + return null; + } + + UUID textureID; + if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID)) + { + AssetBase texture; + + if (!String.IsNullOrEmpty(REDIRECT_URL)) + { + // Only try to fetch locally cached textures. Misses are redirected + texture = m_assetService.GetCached(textureID.ToString()); + + if (texture != null) + { + SendTexture(httpRequest, httpResponse, texture); + } + else + { + string textureUrl = REDIRECT_URL + textureID.ToString(); + m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); + httpResponse.RedirectLocation = textureUrl; + } + } + else + { + // Fetch locally or remotely. Misses return a 404 + texture = m_assetService.Get(textureID.ToString()); + + if (texture != null) + { + SendTexture(httpRequest, httpResponse, texture); + } + else + { + m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; + } + } + } + else + { + m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url); + } + + httpResponse.Send(); + return null; + } + + private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture) + { + string range = request.Headers.GetOne("Range"); + if (!String.IsNullOrEmpty(range)) + { + // Range request + int start, end; + if (TryParseRange(range, out start, out end)) + { + end = Utils.Clamp(end, 1, texture.Data.Length); + start = Utils.Clamp(start, 0, end - 1); + + m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); + + if (end - start < texture.Data.Length) + response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; + + response.ContentLength = end - start; + response.ContentType = texture.Metadata.ContentType; + + response.Body.Write(texture.Data, start, end - start); + } + else + { + m_log.Warn("Malformed Range header: " + range); + response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; + } + } + else + { + // Full content request + response.ContentLength = texture.Data.Length; + response.ContentType = texture.Metadata.ContentType; + response.Body.Write(texture.Data, 0, texture.Data.Length); + } + } + + private bool TryParseRange(string header, out int start, out int end) + { + if (header.StartsWith("bytes=")) + { + string[] rangeValues = header.Substring(6).Split('-'); + if (rangeValues.Length == 2) + { + if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end)) + return true; + } + } + + start = end = 0; + return false; + } + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index af2f3d6..ebd6bbd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -229,6 +229,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return asset; } + public AssetBase GetCached(string id) + { + if (m_Cache != null) + return m_Cache.Get(id); + + return null; + } + public AssetMetadata GetMetadata(string id) { AssetBase asset = null; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 50348da..1b3419d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs @@ -165,6 +165,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return asset; } + public AssetBase GetCached(string id) + { + if (m_Cache != null) + return m_Cache.Get(id); + + return null; + } + public AssetMetadata GetMetadata(string id) { AssetBase asset = null; -- cgit v1.1 From 3d0860ae616749518a40c6f6088d2644d589daf9 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 12 Apr 2010 17:10:51 -0700 Subject: thanks lkalif for Mantis #4676 - a patch that adds support for inventory links Signed-off-by: dahlia --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 34 ++++++++++++++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + 6 files changed, 69 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 51ab281..f0f3932 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -182,6 +182,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event TeleportLocationRequest OnSetStartLocationRequest; public event UpdateAvatarProperties OnUpdateAvatarProperties; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; @@ -4749,6 +4750,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); + AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem); AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); @@ -7348,6 +7350,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } + private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack) + { + LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (createLink.AgentData.SessionID != SessionId || + createLink.AgentData.AgentID != AgentId) + return true; + } + #endregion + + LinkInventoryItem linkInventoryItem = OnLinkInventoryItem; + + if (linkInventoryItem != null) + { + linkInventoryItem( + this, + createLink.InventoryBlock.TransactionID, + createLink.InventoryBlock.FolderID, + createLink.InventoryBlock.CallbackID, + Util.FieldToString(createLink.InventoryBlock.Description), + Util.FieldToString(createLink.InventoryBlock.Name), + createLink.InventoryBlock.InvType, + createLink.InventoryBlock.Type, + createLink.InventoryBlock.OldItemID); + } + + return true; + } + private bool HandleFetchInventory(IClientAPI sender, Packet Pack) { if (OnFetchInventory != null) diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 8d27f9c..09611af 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -129,6 +129,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event Action OnRemoveAvatar; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3b7f38e..7c68ef4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -722,6 +722,37 @@ namespace OpenSim.Region.Framework.Scenes } } + private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, + uint callbackID, string description, string name, + sbyte invType, sbyte type, UUID olditemID) + { + m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); + + if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) + return; + + ScenePresence presence; + if (TryGetScenePresence(remoteClient.AgentId, out presence)) + { + byte[] data = null; + + AssetBase asset = new AssetBase(); + asset.FullID = olditemID; + asset.Type = type; + asset.Name = name; + asset.Description = description; + + CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, name, 0, callbackID, asset, invType, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); + + } + else + { + m_log.ErrorFormat( + "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem", + remoteClient.AgentId); + } + } + /// /// Remove an inventory item for the client's inventory /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fc915a3..685a678 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2749,6 +2749,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientInventoryEvents(IClientAPI client) { client.OnCreateNewInventoryItem += CreateNewInventoryItem; + client.OnLinkInventoryItem += HandleLinkInventoryItem; client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index f5b148f..69e78b3 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -724,6 +724,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event Action OnRemoveAvatar; public event ObjectPermissions OnObjectPermissions; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 338c04b..6360c99 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -235,6 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event Action OnRemoveAvatar; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; -- cgit v1.1 From 54a5b6f4344275342177f6b3c9a2662909dd763a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 12 Apr 2010 12:36:06 -0700 Subject: Reduce number of AvatarAnimations sent with large number of avatars --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 13 +++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 7307662..de4c5fb 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -419,11 +419,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_scenePresence.IsChildAgent) return; - m_scenePresence.Scene.ForEachScenePresence( - delegate(ScenePresence SP) - { - SP.Animator.SendAnimPack(); - }); + UUID[] animIDs; + int[] sequenceNums; + UUID[] objectIDs; + + m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); + client.SendAnimations(animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs); } /// @@ -451,4 +452,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_scenePresence = null; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b5f6217..3efb45f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -912,6 +912,7 @@ namespace OpenSim.Region.Framework.Scenes m_isChildAgent = false; + // send the animations of the other presences to me m_scene.ForEachScenePresence(delegate(ScenePresence presence) { if (presence != this) -- cgit v1.1 From e0f8362e7a24a842a569b692652bc18784a2248b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 Apr 2010 22:31:11 +0100 Subject: minor: add some documentation around the asset udp request path and replace some magic numbers with libomv enums --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 51 ++++++++++++++-------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f0f3932..b3f5f09 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7069,6 +7069,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } + /// + /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request + /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets + /// + /// + /// + /// This parameter may be ignored since we appear to return true whatever happens private bool HandleTransferRequest(IClientAPI sender, Packet Pack) { //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); @@ -7079,7 +7086,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Has to be done here, because AssetCache can't do it // UUID taskID = UUID.Zero; - if (transfer.TransferInfo.SourceType == 3) + if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) { taskID = new UUID(transfer.TransferInfo.Params, 48); UUID itemID = new UUID(transfer.TransferInfo.Params, 64); @@ -11356,17 +11363,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP return String.Empty; } - public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) + /// + /// Make an asset request to the asset service in response to a client request. + /// + /// + /// + protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) { UUID requestID = UUID.Zero; - if (transferRequest.TransferInfo.SourceType == 2) + if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) { - //direct asset request requestID = new UUID(transferRequest.TransferInfo.Params, 0); } - else if (transferRequest.TransferInfo.SourceType == 3) + else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) { - //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); //m_log.Debug("[XXX] inventory asset request " + requestID); //if (taskID == UUID.Zero) // Agent @@ -11379,29 +11389,34 @@ 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("[LLCLIENTVIEW]: {0} requesting asset {1}", Name, requestID); m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); - } + /// + /// When we get a reply back from the asset service in response to a client request, send back the data. + /// + /// + /// + /// protected void AssetReceived(string id, Object sender, AssetBase asset) { TransferRequestPacket transferRequest = (TransferRequestPacket)sender; UUID requestID = UUID.Zero; - byte source = 2; - if ((transferRequest.TransferInfo.SourceType == 2) || (transferRequest.TransferInfo.SourceType == 2222)) + byte source = (byte)SourceType.Asset; + + if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) + || (transferRequest.TransferInfo.SourceType == 2222)) { - //direct asset request requestID = new UUID(transferRequest.TransferInfo.Params, 0); } - else if ((transferRequest.TransferInfo.SourceType == 3) || (transferRequest.TransferInfo.SourceType == 3333)) + else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) + || (transferRequest.TransferInfo.SourceType == 3333)) { - //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); - source = 3; + source = (byte)SourceType.SimInventoryItem; //m_log.Debug("asset request " + requestID); } @@ -11414,9 +11429,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) { m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); - if (transferRequest.TransferInfo.SourceType == 2) + if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) transferRequest.TransferInfo.SourceType = 2222; // marker - else if (transferRequest.TransferInfo.SourceType == 3) + else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) transferRequest.TransferInfo.SourceType = 3333; // marker m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); @@ -11431,7 +11446,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // Scripts cannot be retrieved by direct request - if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) + if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10) return; // The asset is known to exist and is in our cache, so add it to the AssetRequests list -- cgit v1.1 From 8fa13e387110233e2a38ceb41906f65992f014e5 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 14 Apr 2010 19:48:40 -0700 Subject: Patch from mcortez to add basic caching to the groups module. This prevents database/network explosions when you have a significant number of group-owned prims in a scene --- .../SimianGroupsServicesConnectorModule.cs | 81 +++++++++++-- .../XmlRpcGroupsServicesConnectorModule.cs | 131 ++++++++++++++------- 2 files changed, 160 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 669373f..9363205 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs @@ -167,6 +167,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private bool m_debugEnabled = false; + private ExpiringCache m_memoryCache; + private int m_cacheTimeout = 30; + // private IUserAccountService m_accountService = null; @@ -203,7 +206,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } - m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); + m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); if ((m_groupsServerURI == null) || @@ -214,6 +217,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } + + m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); + if (m_cacheTimeout == 0) + { + m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled."); + } + else + { + m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout); + } + + + + m_memoryCache = new ExpiringCache(); + + // If we got all the config options we need, lets start'er'up m_connectorEnabled = true; @@ -224,7 +243,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups public void Close() { - m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); + m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name); } public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) @@ -657,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); + OSDMap response = CachedPostRequest(requestArgs); if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) { OSDArray entryArray = (OSDArray)response["Entries"]; @@ -1086,7 +1105,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); + OSDMap Response = CachedPostRequest(RequestArgs); if (Response["Success"].AsBoolean()) { return true; @@ -1113,7 +1132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); + OSDMap Response = CachedPostRequest(RequestArgs); if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) { OSDArray entryArray = (OSDArray)Response["Entries"]; @@ -1153,7 +1172,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); + OSDMap Response = CachedPostRequest(RequestArgs); if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) { OSDArray entryArray = (OSDArray)Response["Entries"]; @@ -1194,7 +1213,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); + OSDMap Response = CachedPostRequest(RequestArgs); if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) { OSDArray entryArray = (OSDArray)Response["Entries"]; @@ -1234,7 +1253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups - OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); + OSDMap response = CachedPostRequest(requestArgs); if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) { maps = new Dictionary(); @@ -1272,7 +1291,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups - OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); + OSDMap response = CachedPostRequest(requestArgs); if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) { maps = new Dictionary(); @@ -1310,7 +1329,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups }; - OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); + OSDMap response = CachedPostRequest(requestArgs); if (response["Success"].AsBoolean()) { return true; @@ -1323,6 +1342,48 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } #endregion + #region CheesyCache + OSDMap CachedPostRequest(NameValueCollection requestArgs) + { + // Immediately forward the request if the cache is disabled. + if (m_cacheTimeout == 0) + { + return WebUtil.PostToService(m_groupsServerURI, requestArgs); + } + + // Check if this is an update or a request + if ( requestArgs["RequestMethod"] == "RemoveGeneric" + || requestArgs["RequestMethod"] == "AddGeneric" + ) + + { + // Any and all updates cause the cache to clear + m_memoryCache.Clear(); + + // Send update to server, return the response without caching it + return WebUtil.PostToService(m_groupsServerURI, requestArgs); + + } + + // If we're not doing an update, we must be requesting data + + // Create the cache key for the request and see if we have it cached + string CacheKey = WebUtil.BuildQueryString(requestArgs); + OSDMap response = null; + if (!m_memoryCache.TryGetValue(CacheKey, out response)) + { + // if it wasn't in the cache, pass the request to the Simian Grid Services + response = WebUtil.PostToService(m_groupsServerURI, requestArgs); + + // and cache the response + m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout)); + } + + // return cached response + return response; + } + #endregion + } } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 523dfbe..e7967d1 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; @@ -70,6 +71,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private IUserAccountService m_accountService = null; + 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 @@ -111,7 +115,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } - m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); + m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); if ((m_groupsServerURI == null) || @@ -127,7 +131,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); - + + 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 @@ -137,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups public void Close() { - m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); + m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name); } public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) @@ -919,50 +932,84 @@ 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()); - + XmlRpcResponse resp = null; + string CacheKey = null; + + // Only bother with the cache if it isn't disabled. + if (m_cacheTimeout > 0) + { + 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); + } - param.Add("ReadKey", m_groupReadKey); - param.Add("WriteKey", m_groupWriteKey); + } + + 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()); - IList parameters = new ArrayList(); - parameters.Add(param); + param.Add("ReadKey", m_groupReadKey); + param.Add("WriteKey", m_groupWriteKey); - ConfigurableKeepAliveXmlRpcRequest req; - req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); - XmlRpcResponse resp = null; + IList parameters = new ArrayList(); + parameters.Add(param); - try - { - resp = req.Send(m_groupsServerURI, 10000); - } - catch (Exception e) - { - + ConfigurableKeepAliveXmlRpcRequest req; + req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); - 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()); - foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) + 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("[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", e.ToString()); + + foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) + { + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine); + } + + foreach (string key in param.Keys) + { + m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {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; } if (resp.Value is Hashtable) @@ -976,21 +1023,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return respData; } - m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); if (resp.Value is ArrayList) { ArrayList al = (ArrayList)resp.Value; - m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count); foreach (object o in al) { - m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString()); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString()); } } else { - m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString()); } Hashtable error = new Hashtable(); @@ -1000,16 +1047,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void LogRespDataToConsoleError(Hashtable respData) { - m_log.Error("[XMLRPCGROUPDATA]: Error:"); + m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:"); foreach (string key in respData.Keys) { - m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key); string[] lines = respData[key].ToString().Split(new char[] { '\n' }); foreach (string line in lines) { - m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); + m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); } } -- cgit v1.1 From 9131a0d4a4ec24e3216c65cdf4b00af79c07a046 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 21:12:09 +0100 Subject: minor: stop datasnapshot issuing a warning log message if it's disabled --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 6949d7c..9fc002b 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.DataSnapshot if (!m_configLoaded) { m_configLoaded = true; - m_log.Info("[DATASNAPSHOT]: Loading configuration"); + //m_log.Debug("[DATASNAPSHOT]: Loading configuration"); //Read from the config for options lock (m_syncInit) { @@ -123,7 +123,7 @@ namespace OpenSim.Region.DataSnapshot } catch (Exception) { - m_log.Info("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); + m_log.Warn("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); m_enabled = false; return; } @@ -179,7 +179,7 @@ namespace OpenSim.Region.DataSnapshot } else { - m_log.Warn("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); + //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); } } -- cgit v1.1 From 5459a90fc6b3864b90a10cd99e4e5a3a0e92d226 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 21:23:01 +0100 Subject: minor: stop irc bridge warning about not attached to regions if it's not been turned on in the first place --- OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs index e664b44..d49a489 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat } else { - m_log.WarnFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName); + //m_log.DebugFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName); } } -- cgit v1.1 From cf4673585616e4b45f095ec5837c2554f40b85b3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 21:39:27 +0100 Subject: add a missing initialization of the m_memoryCache in XmlRpcGroupsServicesConnectorModule the lack of this caused me a NullReferenceException when calling some groups methods directly though in principle it would also fail in other situations --- .../Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index e7967d1..79b9a16 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs @@ -142,8 +142,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 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; } } -- cgit v1.1 From bf3956aeb0a44d0dd455e330234fcf0e18f5ea43 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 22:29:11 +0100 Subject: Add --skip-assets option to load oar. This allows you to load an oar without loading its assets. This is useful if you know that the required assets are already in the asset service, since loading without assets is quicker. This option will become more useful when the ability to save oars without assets is added, which should happen fairly soon. At this point there will also be better documentation. --- OpenSim/Region/Application/OpenSim.cs | 5 +-- .../World/Archiver/ArchiveReadRequest.cs | 40 ++++++++++++++-------- .../CoreModules/World/Archiver/ArchiverModule.cs | 19 +++++----- .../World/Archiver/Tests/ArchiverTests.cs | 2 +- .../Framework/Interfaces/IRegionArchiverModule.cs | 12 +++++-- 5 files changed, 50 insertions(+), 28 deletions(-) mode change 100755 => 100644 OpenSim/Region/Application/OpenSim.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs old mode 100755 new mode 100644 index 38b2084..1395030 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -251,8 +251,9 @@ namespace OpenSim "Save named prim to XML2", SavePrimsXml2); m_console.Commands.AddCommand("region", false, "load oar", - "load oar [--merge] ", - "Load a region's data from OAR archive", LoadOar); + "load oar [--merge] [--skip-assets] ", + "Load a region's data from OAR archive. --merge will merge the oar with the existing scene. --skip-assets will load the oar but ignore the assets it contains", + LoadOar); m_console.Commands.AddCommand("region", false, "save oar", "save oar ", diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index b1b2336f8..cde7c93 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -53,25 +53,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); - private static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); + protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); + protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); - private Scene m_scene; - private Stream m_loadStream; - private Guid m_requestId; - private string m_errorMessage; + protected Scene m_scene; + protected Stream m_loadStream; + protected Guid m_requestId; + protected string m_errorMessage; /// /// Should the archive being loaded be merged with what is already on the region? /// - private bool m_merge; + protected bool m_merge; + + /// + /// Should we ignore any assets when reloading the archive? + /// + protected bool m_skipAssets; /// /// Used to cache lookups for valid uuids. /// private IDictionary m_validUserUuids = new Dictionary(); - public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) + public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) { m_scene = scene; @@ -89,14 +94,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_errorMessage = String.Empty; m_merge = merge; + m_skipAssets = skipAssets; m_requestId = requestId; } - public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) + public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) { m_scene = scene; m_loadStream = loadStream; m_merge = merge; + m_skipAssets = skipAssets; m_requestId = requestId; } @@ -135,7 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); } - else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) + else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets) { if (LoadAsset(filePath, data)) successfulAssetRestores++; @@ -178,12 +185,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver archive.Close(); } - m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); - - if (failedAssetRestores > 0) + if (!m_skipAssets) { - m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); - m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); + m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); + + if (failedAssetRestores > 0) + { + m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); + m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); + } } if (!m_merge) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index fc8d4e1..82ede01 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) { bool mergeOar = false; + bool skipAssets = false; OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); + options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); + List mainParams = options.Parse(cmdparams); // m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); @@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (mainParams.Count > 2) { - DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); + DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty); } else { - DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); + DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty); } } @@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void DearchiveRegion(string loadPath) { - DearchiveRegion(loadPath, false, Guid.Empty); + DearchiveRegion(loadPath, false, false, Guid.Empty); } - public void DearchiveRegion(string loadPath, bool merge, Guid requestId) + public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId) { m_log.InfoFormat( "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); - new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); + new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion(); } public void DearchiveRegion(Stream loadStream) { - DearchiveRegion(loadStream, false, Guid.Empty); + DearchiveRegion(loadStream, false, false, Guid.Empty); } - public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) + public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId) { - new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); + new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index de16d89..624dc22 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); - m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); + m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty); SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 991d60c..89e59d0 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs @@ -90,8 +90,12 @@ namespace OpenSim.Region.Framework.Interfaces /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region /// settings in the archive will be ignored. /// + /// + /// If true, the archive is loaded without loading any assets contained within it. This is useful if the + /// assets are already known to be present in the grid's asset service. + /// /// If supplied, this request Id is later returned in the saved event - void DearchiveRegion(string loadPath, bool merge, Guid requestId); + void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId); /// /// Dearchive a region from a stream. This replaces the existing scene. @@ -113,7 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region /// settings in the archive will be ignored. /// + /// + /// If true, the archive is loaded without loading any assets contained within it. This is useful if the + /// assets are already known to be present in the grid's asset service. + /// If supplied, this request Id is later returned in the saved event - void DearchiveRegion(Stream loadStream, bool merge, Guid requestId); + void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId); } } -- cgit v1.1 From e9926d13cf72ede89686147b38425fea806caeb0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 22:38:42 +0100 Subject: minor: use the static ascii and utf8 encodings instead of instantiating our own --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index cde7c93..55028d0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -53,9 +53,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); - protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); - protected Scene m_scene; protected Stream m_loadStream; protected Guid m_requestId; @@ -140,7 +137,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) { - serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); + serialisedSceneObjects.Add(Encoding.UTF8.GetString(data)); } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets) { @@ -162,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) { - serialisedParcels.Add(m_utf8Encoding.GetString(data)); + serialisedParcels.Add(Encoding.UTF8.GetString(data)); } else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { @@ -551,7 +548,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); XmlTextReader xtr - = new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context); + = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; -- cgit v1.1 From 17d023ba5bb54f832adc8c0d4ba79b2a0e67c434 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 22:54:25 +0100 Subject: refactor: crudely move the RezMultipleAttachments() method into the AttachmentsModule --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++++++++++ OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | 12 ++++++++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 ---------- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++---- 4 files changed, 28 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 23828ef..37f790d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -30,6 +30,7 @@ using System.Reflection; using log4net; using Nini.Config; using OpenMetaverse; +using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; @@ -169,6 +170,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return true; } + public void RezMultipleAttachmentsFromInventory( + IClientAPI remoteClient, + RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, + RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) + { + foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) + { + RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt); + } + } + public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name); diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 0222b02..77e9a7e 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -27,6 +27,7 @@ using System; using OpenMetaverse; +using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; @@ -82,6 +83,17 @@ namespace OpenSim.Region.Framework.Interfaces IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); /// + /// Rez multiple attachments from a user's inventory + /// + /// + /// + /// + void RezMultipleAttachmentsFromInventory( + IClientAPI remoteClient, + RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, + RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); + + /// /// Update the user inventory to the attachment of an item /// /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7c68ef4..4a286ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -35,7 +35,6 @@ using OpenMetaverse; using OpenMetaverse.Packets; using log4net; using OpenSim.Framework; - using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Serialization; @@ -1875,15 +1874,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnAttach(localID, itemID, avatarID); } - public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, - RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) - { - foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) - { - AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt); - } - } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) { SceneObjectPart part = GetSceneObjectPart(itemID); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 685a678..d4da2cb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2769,13 +2769,13 @@ namespace OpenSim.Region.Framework.Scenes } public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) - { - client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; + { client.OnObjectDetach += m_sceneGraph.DetachObject; if (AttachmentsModule != null) { client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; client.OnObjectAttach += AttachmentsModule.AttachObject; client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; } @@ -2926,12 +2926,12 @@ namespace OpenSim.Region.Framework.Scenes public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) { - client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; client.OnObjectDetach -= m_sceneGraph.DetachObject; if (AttachmentsModule != null) { - client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; + client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; client.OnObjectAttach -= AttachmentsModule.AttachObject; client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; } -- cgit v1.1 From 45563e20e0167cd0349503919a96658ca119d11e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 22:57:44 +0100 Subject: minor: correctly print out missing item id when it can't be found rather than a NullReferenceException --- .../ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | 5 ++++- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index e97d21f..a2f26d5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -311,10 +311,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); + UUID requestedItemId = item.ID; + item = m_InventoryService.GetItem(item); if (null == item) - m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); + m_log.ErrorFormat( + "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", requestedItemId); return item; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4a286ac..a90c4b3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -471,7 +471,6 @@ namespace OpenSim.Region.Framework.Scenes return null; } - if (recipientParentFolderId == UUID.Zero) { InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); -- cgit v1.1 From 57c293d604874c8033a602d1cea6f5250769ff14 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 23:15:13 +0100 Subject: refactor: crudely move DetachSingleAttachmentToGround() over to the AttachmentsModule --- .../Avatar/Attachments/AttachmentsModule.cs | 32 ++++++++++++++++++++++ .../Framework/Interfaces/IAttachmentsModule.cs | 7 +++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 30 -------------------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 +-- 4 files changed, 40 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 37f790d..f8fb7ca 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -341,6 +341,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments DetachSingleAttachmentToInv(itemID, remoteClient); } + public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); + if (part == null || part.ParentGroup == null) + return; + + UUID inventoryID = part.ParentGroup.GetFromItemID(); + + ScenePresence presence; + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + { + if (!m_scene.Permissions.CanRezObject( + part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) + return; + + presence.Appearance.DetachAttachment(itemID); + + if (m_scene.AvatarFactory != null) + { + m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } + part.ParentGroup.DetachToGround(); + + List uuids = new List(); + uuids.Add(inventoryID); + m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); + remoteClient.SendRemoveInventoryItem(inventoryID); + } + + m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); + } + // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 77e9a7e..d43ce1f 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -92,6 +92,13 @@ namespace OpenSim.Region.Framework.Interfaces IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); + + /// + /// Detach the given item to the ground. + /// + /// + /// + void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); /// /// Update the user inventory to the attachment of an item diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a90c4b3..e3f1636 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1873,36 +1873,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnAttach(localID, itemID, avatarID); } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) - { - SceneObjectPart part = GetSceneObjectPart(itemID); - if (part == null || part.ParentGroup == null) - return; - - UUID inventoryID = part.ParentGroup.GetFromItemID(); - - ScenePresence presence; - if (TryGetScenePresence(remoteClient.AgentId, out presence)) - { - if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) - return; - - presence.Appearance.DetachAttachment(itemID); - IAvatarFactory ava = RequestModuleInterface(); - if (ava != null) - { - ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); - } - part.ParentGroup.DetachToGround(); - - List uuids = new List(); - uuids.Add(inventoryID); - InventoryService.DeleteItems(remoteClient.AgentId, uuids); - remoteClient.SendRemoveInventoryItem(inventoryID); - } - SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); - } - public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 23a4ee9..89eb54d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -443,9 +443,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup group = GetGroupByPrim(objectLocalID); if (group != null) - { - m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient); - } + m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient); } protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) -- cgit v1.1 From ab3af43d5e363a47d103f75f8ee346f476dbe15d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Apr 2010 23:29:36 +0100 Subject: refactor: remove now unused internal method SendAttachEvent() --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e3f1636..7661068 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1868,11 +1868,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerStopScript(part.LocalId, itemID); } - internal void SendAttachEvent(uint localID, UUID itemID, UUID avatarID) - { - EventManager.TriggerOnAttach(localID, itemID, avatarID); - } - public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); -- cgit v1.1 From 26e38842372e934937be36a21d8a99742cd485fe Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Apr 2010 00:00:45 +0100 Subject: refactor: move DeatchObject() into the AttachmentsModule --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 ++++++++++ OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | 10 ++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++------ 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f8fb7ca..c87a383 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -323,6 +323,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } + public void DetachObject(uint objectLocalID, IClientAPI remoteClient) + { + SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); + if (group != null) + { + //group.DetachToGround(); + ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); + } + } + public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index d43ce1f..f8af367 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -94,6 +94,16 @@ namespace OpenSim.Region.Framework.Interfaces RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); /// + /// Detach an object from the avatar. + /// + /// + /// This method is called in response to a client's detach request, so we only update the information in + /// inventory + /// + /// + void DetachObject(uint objectLocalID, IClientAPI remoteClient); + + /// /// Detach the given item to the ground. /// /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d4da2cb..a34f57e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2769,14 +2769,13 @@ namespace OpenSim.Region.Framework.Scenes } public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) - { - client.OnObjectDetach += m_sceneGraph.DetachObject; - + { if (AttachmentsModule != null) { client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; client.OnObjectAttach += AttachmentsModule.AttachObject; + client.OnObjectDetach += AttachmentsModule.DetachObject; client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; } } @@ -2925,14 +2924,13 @@ namespace OpenSim.Region.Framework.Scenes } public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) - { - client.OnObjectDetach -= m_sceneGraph.DetachObject; - + { if (AttachmentsModule != null) { client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; client.OnObjectAttach -= AttachmentsModule.AttachObject; + client.OnObjectDetach -= AttachmentsModule.DetachObject; client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; } } -- cgit v1.1 From 21cad5d3ac68ceb4ac48346835ac087ecb107446 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 19 Apr 2010 06:29:26 +0100 Subject: All scripts are now created suspended and are only unsuspended when the object is fully rezzed and all scripts in it are instantiated. This ensures that link messages will not be lost on rez/region crossing and makes heavily scripted objects reliable. --- .../Avatar/Attachments/AttachmentsModule.cs | 3 ++- .../InventoryAccess/InventoryAccessModule.cs | 1 + .../World/Archiver/ArchiveReadRequest.cs | 1 + .../Framework/Interfaces/IEntityInventory.cs | 1 + .../Region/Framework/Interfaces/IScriptModule.cs | 8 +++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 + .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 8 +++++++ .../Framework/Scenes/SceneObjectPartInventory.cs | 25 +++++++++++++++++++++- .../Scenes/Serialization/SceneXmlLoader.cs | 1 + .../ScriptEngine/Interfaces/IScriptInstance.cs | 3 +++ .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 14 ++++++++++++ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 18 ++++++++++++++++ 14 files changed, 85 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c87a383..77e73fb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -250,6 +250,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID, remoteClient.Name, AttachmentPt); } + objatt.ResumeScripts(); return objatt; } @@ -413,4 +414,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 16e05b7..32a0df9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -621,6 +621,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } + rootPart.ParentGroup.ResumeScripts(); return rootPart.ParentGroup; } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 55028d0..c52f029 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -284,6 +284,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { sceneObjectsLoadedCount++; sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); + sceneObject.ResumeScripts(); } } diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index f58904f..2b90960 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -74,6 +74,7 @@ namespace OpenSim.Region.Framework.Interfaces void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); ArrayList GetScriptErrors(UUID itemID); + void ResumeScripts(); /// /// Stop all the scripts in this entity. diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index e90b300..fecdd1b 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -41,6 +41,14 @@ namespace OpenSim.Region.Framework.Interfaces bool PostScriptEvent(UUID itemID, string name, Object[] args); bool PostObjectEvent(UUID itemID, string name, Object[] args); + // Suspend ALL scripts in a given scene object. The item ID + // is the UUID of a SOG, and the method acts on all contained + // scripts. This is different from the suspend/resume that + // can be issued by a client. + // + void SuspendScript(UUID itemID); + void ResumeScript(UUID itemID); + ArrayList GetScriptErrors(UUID itemID); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7661068..435026c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes if (group is SceneObjectGroup) { ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); + ((SceneObjectGroup) group).ResumeScripts(); } } } @@ -218,6 +219,7 @@ namespace OpenSim.Region.Framework.Scenes { remoteClient.SendAgentAlertMessage("Script saved", false); } + part.ParentGroup.ResumeScripts(); return errors; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a34f57e..57587be 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1131,7 +1131,6 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scripts_enabled != !ScriptEngine) { - // Tedd! Here's the method to disable the scripting engine! if (ScriptEngine) { m_log.Info("Stopping all Scripts in Scene"); @@ -1153,6 +1152,7 @@ namespace OpenSim.Region.Framework.Scenes if (ent is SceneObjectGroup) { ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); + ((SceneObjectGroup)ent).ResumeScripts(); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 89eb54d..1421d0e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1755,6 +1755,7 @@ namespace OpenSim.Region.Framework.Scenes copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); copy.HasGroupChanged = true; copy.ScheduleGroupForFullUpdate(); + copy.ResumeScripts(); // required for physics to update it's position copy.AbsolutePosition = copy.AbsolutePosition; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 4034744..f7e46af 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -416,5 +416,13 @@ namespace OpenSim.Region.Framework.Scenes scriptModule.SetXMLState(itemID, n.OuterXml); } } + + public void ResumeScripts() + { + foreach (SceneObjectPart part in m_parts.Values) + { + part.Inventory.ResumeScripts(); + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2e13f90..2b6be29 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1042,5 +1042,28 @@ namespace OpenSim.Region.Framework.Scenes return ret; } + + public void ResumeScripts() + { + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + if (engines == null) + return; + + + lock (m_items) + { + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.InvType == (int)InventoryType.LSL) + { + foreach (IScriptModule engine in engines) + { + if (engine != null) + engine.ResumeScript(item.ItemID); + } + } + } + } + } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index cf0f345..b6677f0 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -182,6 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization foreach (SceneObjectGroup sceneObject in sceneObjects) { sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); + sceneObject.ResumeScripts(); } } diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index ae148a9..9f6ea35 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -81,6 +81,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces void PostEvent(EventParams data); + void Suspend(); + void Resume(); + /// /// Process the next event queued for this script /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index d30d2dc..74f25aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private bool m_startedFromSavedState; private UUID m_CurrentStateHash; private UUID m_RegionID; + private bool m_Suspended = true; private Dictionary, KeyValuePair> m_LineMap; @@ -638,6 +639,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { + if (m_Suspended) + return 0; + lock (m_Script) { EventParams data = null; @@ -1011,5 +1015,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { get { return m_RegionID; } } + + public void Suspend() + { + m_Suspended = true; + } + + public void Resume() + { + m_Suspended = false; + } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 98e77c0..54074ed 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1488,5 +1488,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine return new ArrayList(); } } + + public void SuspendScript(UUID itemID) + { + IScriptInstance instance = GetInstance(itemID); + if (instance == null) + return; + + instance.Suspend(); + } + + public void ResumeScript(UUID itemID) + { + IScriptInstance instance = GetInstance(itemID); + if (instance == null) + return; + + instance.Resume(); + } } } -- cgit v1.1