From b1a5c0398551e4051f84d8bf3acf46b18fbe739d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 6 Dec 2010 17:40:07 +0100 Subject: [PATCH 1/4] Lock the attachments dict so it doesn't get out of sync when iterating --- OpenSim/Framework/AvatarAppearance.cs | 94 +++++++++++++++++---------- 1 file changed, 59 insertions(+), 35 deletions(-) diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index d0c8b73126..be15e1bf92 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -414,27 +414,36 @@ namespace OpenSim.Framework /// public List GetAttachments() { - List alist = new List(); - foreach (KeyValuePair> kvp in m_attachments) + lock (m_attachments) { - foreach (AvatarAttachment attach in kvp.Value) - alist.Add(new AvatarAttachment(attach)); - } + List alist = new List(); + foreach (KeyValuePair> kvp in m_attachments) + { + foreach (AvatarAttachment attach in kvp.Value) + alist.Add(new AvatarAttachment(attach)); + } - return alist; + return alist; + } } internal void AppendAttachment(AvatarAttachment attach) { - if (! m_attachments.ContainsKey(attach.AttachPoint)) - m_attachments[attach.AttachPoint] = new List(); - m_attachments[attach.AttachPoint].Add(attach); + lock (m_attachments) + { + if (!m_attachments.ContainsKey(attach.AttachPoint)) + m_attachments[attach.AttachPoint] = new List(); + m_attachments[attach.AttachPoint].Add(attach); + } } internal void ReplaceAttachment(AvatarAttachment attach) { - m_attachments[attach.AttachPoint] = new List(); - m_attachments[attach.AttachPoint].Add(attach); + lock (m_attachments) + { + m_attachments[attach.AttachPoint] = new List(); + m_attachments[attach.AttachPoint].Add(attach); + } } /// @@ -450,9 +459,12 @@ namespace OpenSim.Framework if (item == UUID.Zero) { - if (m_attachments.ContainsKey(attachpoint)) - m_attachments.Remove(attachpoint); - return; + lock (m_attachments) + { + if (m_attachments.ContainsKey(attachpoint)) + m_attachments.Remove(attachpoint); + return; + } } // check if this is an append or a replace, 0x80 marks it as an append @@ -470,37 +482,46 @@ namespace OpenSim.Framework public int GetAttachpoint(UUID itemID) { - foreach (KeyValuePair> kvp in m_attachments) + lock (m_attachments) { - int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); - if (index >= 0) - return kvp.Key; - } + foreach (KeyValuePair> kvp in m_attachments) + { + int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); + if (index >= 0) + return kvp.Key; + } - return 0; + return 0; + } } public void DetachAttachment(UUID itemID) { - foreach (KeyValuePair> kvp in m_attachments) + lock (m_attachments) { - int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); - if (index >= 0) + foreach (KeyValuePair> kvp in m_attachments) { - // Remove it from the list of attachments at that attach point - m_attachments[kvp.Key].RemoveAt(index); + int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); + if (index >= 0) + { + // Remove it from the list of attachments at that attach point + m_attachments[kvp.Key].RemoveAt(index); - // And remove the list if there are no more attachments here - if (m_attachments[kvp.Key].Count == 0) - m_attachments.Remove(kvp.Key); - return; + // And remove the list if there are no more attachments here + if (m_attachments[kvp.Key].Count == 0) + m_attachments.Remove(kvp.Key); + return; + } } } } public void ClearAttachments() { - m_attachments.Clear(); + lock (m_attachments) + { + m_attachments.Clear(); + } } #region Packing Functions @@ -537,11 +558,14 @@ namespace OpenSim.Framework OSDBinary visualparams = new OSDBinary(m_visualparams); data["visualparams"] = visualparams; - // Attachments - OSDArray attachs = new OSDArray(m_attachments.Count); - foreach (AvatarAttachment attach in GetAttachments()) - attachs.Add(attach.Pack()); - data["attachments"] = attachs; + lock (m_attachments) + { + // Attachments + OSDArray attachs = new OSDArray(m_attachments.Count); + foreach (AvatarAttachment attach in GetAttachments()) + attachs.Add(attach.Pack()); + data["attachments"] = attachs; + } return data; } From b960a05e67b4aed543e37f4e041f0d5e5cc2d7c0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 Dec 2010 01:07:13 +0100 Subject: [PATCH 2/4] Cowardly refuse to keep running when no application plugins are loaded. Prevents empty instances from hanging around when Mono.Addins messes up --- OpenSim/Region/Application/OpenSimBase.cs | 6 ++++++ .../AgentAssetsTransactions.cs | 6 ++++++ .../AssetTransaction/AssetXferUploader.cs | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 6a7272df9d..941472b332 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -222,6 +222,12 @@ namespace OpenSim m_moduleLoader = new ModuleLoader(m_config.Source); LoadPlugins(); + + if (m_plugins.Count == 0) // We failed to load any modules. Mono Addins glitch! + { + Environment.Exit(1); + } + foreach (IApplicationPlugin plugin in m_plugins) { plugin.PostInitialise(); diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 85e1c9949d..d7f3f2c048 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -167,6 +167,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { + m_log.DebugFormat("[XFER]: Asked to update item {0} ({1})", + item.Name, item.ID); + // Here we need to get the old asset to extract the // texture UUIDs if it's a wearable. if (item.AssetType == (int)AssetType.Bodypart || @@ -191,6 +194,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction IInventoryService invService = m_Scene.InventoryService; invService.UpdateItem(item); + + m_log.DebugFormat("[XFER]: Updated item {0} ({1}) with asset {2}", + item.Name, item.ID, asset.FullID); } } } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index b8c8c85478..a5dcdccf56 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -40,7 +40,12 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction public class AssetXferUploader { // Viewer's notion of the default texture - private UUID defaultID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); + private List defaultIDs = new List { + new UUID("5748decc-f629-461c-9a36-a35a221fe21f"), + new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"), + new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"), + new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97") + }; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private AssetBase m_asset; @@ -244,6 +249,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.Flags = (uint) wearableType; item.CreationDate = Util.UnixTimeSinceEpoch(); + m_log.DebugFormat("[XFER]: Created item {0} with asset {1}", + item.ID, item.AssetID); + if (m_Scene.AddInventoryItem(item)) ourClient.SendInventoryItemCreateUpdate(item, callbackID); else @@ -280,7 +288,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction UUID tx = new UUID(parts[1]); int id = Convert.ToInt32(parts[0]); - if (tx == defaultID || tx == UUID.Zero || + if (defaultIDs.Contains(tx) || tx == UUID.Zero || (allowed.ContainsKey(id) && allowed[id] == tx)) { validated.Add(parts[0] + " " + tx.ToString()); @@ -293,7 +301,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if ((perms & full) != full) { m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); - validated.Add(parts[0] + " " + defaultID.ToString()); + validated.Add(parts[0] + " " + UUID.Zero.ToString()); + } + else + { + validated.Add(line); } } textures--; From a4f7937eb338df588c02ce44200876210d0d58c3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 Dec 2010 03:08:48 +0100 Subject: [PATCH 3/4] Add the interface needed to revive calling cards --- OpenSim/Framework/ICallingCardModule.cs | 13 +++++++++++++ .../CoreModules/Avatar/Friends/FriendsModule.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 OpenSim/Framework/ICallingCardModule.cs diff --git a/OpenSim/Framework/ICallingCardModule.cs b/OpenSim/Framework/ICallingCardModule.cs new file mode 100644 index 0000000000..6e343bbd3b --- /dev/null +++ b/OpenSim/Framework/ICallingCardModule.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Framework +{ + public interface ICallingCardModule + { + void CreateCallingCard(UUID userID, UUID creatorID, UUID folderID); + } +} diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 45c3f49420..613a054fb2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -516,6 +516,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends FriendsService.StoreFriend(agentID, friendID.ToString(), 1); FriendsService.StoreFriend(friendID, agentID.ToString(), 1); + ICallingCardModule ccm = client.Scene.RequestModuleInterface(); + if (ccm != null) + { + ccm.CreateCallingCard(agentID, friendID, UUID.Zero); + } + // Update the local cache UpdateFriendsCache(agentID); @@ -679,6 +685,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); friendClient.SendInstantMessage(im); + ICallingCardModule ccm = friendClient.Scene.RequestModuleInterface(); + if (ccm != null) + { + ccm.CreateCallingCard(friendID, userID, UUID.Zero); + } + + // Update the local cache UpdateFriendsCache(friendID); From 549f90c5b51939fa40439a65baa15f8664529958 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 Dec 2010 04:45:28 +0100 Subject: [PATCH 4/4] Update calling card interface --- OpenSim/Framework/ICallingCardModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/ICallingCardModule.cs b/OpenSim/Framework/ICallingCardModule.cs index 6e343bbd3b..17e6de35b6 100644 --- a/OpenSim/Framework/ICallingCardModule.cs +++ b/OpenSim/Framework/ICallingCardModule.cs @@ -8,6 +8,6 @@ namespace OpenSim.Framework { public interface ICallingCardModule { - void CreateCallingCard(UUID userID, UUID creatorID, UUID folderID); + UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID); } }