From ea0f78c97152d3aa54822487e5343ca2db0b47b9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 12 Sep 2011 21:57:22 +0100
Subject: Start locking entire add/remove operations on an
IScenePresence.AttachmentsSyncLock object
Attach and detach packets are processed asynchronously when received from a viewer.
Bugs like http://opensimulator.org/mantis/view.php?id=5644 indicate that in some situations (such as attaching/detaching entire folders of objects at once), there are race conditions between these threads.
Since multiple data structures need to be updated on attach/detach, it's not enough to lock the individual collections.
Therefore, this commit introduces a new IScenePresence.AttachmentsSyncLock which add/remove operations lock on.
---
OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | 9 +++++++++
OpenSim/Region/Framework/Interfaces/IScenePresence.cs | 8 ++++++++
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++
3 files changed, 21 insertions(+)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 73d15a5..e6ac6b5 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -88,6 +88,15 @@ namespace OpenSim.Region.Framework.Interfaces
ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
///
+ /// Rez an attachment from user inventory and change inventory status to match.
+ ///
+ ///
+ ///
+ ///
+ /// The scene object that was attached. Null if the scene object could not be found
+ ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt);
+
+ ///
/// Rez multiple attachments from a user's inventory
///
///
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 8913133..95688ab 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -61,6 +61,14 @@ namespace OpenSim.Region.Framework.Interfaces
AvatarAppearance Appearance { get; set; }
///
+ /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
+ ///
+ ///
+ /// All add and remove attachment operations must synchronize on this for the lifetime of their operations.
+ ///
+ Object AttachmentsSyncLock { get; }
+
+ ///
/// The scene objects attached to this avatar.
///
///
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index d65d78d..86e1e11 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -120,6 +120,8 @@ namespace OpenSim.Region.Framework.Scenes
///
protected List m_attachments = new List();
+ public Object AttachmentsSyncLock { get; private set; }
+
private Dictionary scriptedcontrols = new Dictionary();
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
@@ -709,6 +711,8 @@ namespace OpenSim.Region.Framework.Scenes
public ScenePresence(
IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type)
{
+ AttachmentsSyncLock = new Object();
+
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
m_sceneViewer = new SceneViewer(this);
m_animator = new ScenePresenceAnimator(this);
--
cgit v1.1