Lock updates out while linking and unlinking

mysql-performance
Melanie 2009-12-06 00:25:04 +00:00
parent e3a22ff37d
commit 46d5add175
1 changed files with 146 additions and 133 deletions

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Threading;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
@ -96,6 +97,8 @@ namespace OpenSim.Region.Framework.Scenes
protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
private readonly Object m_dictionary_lock = new Object(); private readonly Object m_dictionary_lock = new Object();
private Object m_updateLock = new Object();
#endregion #endregion
protected internal SceneGraph(Scene parent, RegionInfo regInfo) protected internal SceneGraph(Scene parent, RegionInfo regInfo)
@ -369,6 +372,9 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
protected internal void UpdateObjectGroups() protected internal void UpdateObjectGroups()
{ {
if (!Monitor.TryEnter(m_updateLock))
return;
List<SceneObjectGroup> updates; List<SceneObjectGroup> updates;
// Some updates add more updates to the updateList. // Some updates add more updates to the updateList.
@ -395,6 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
"[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e);
} }
} }
Monitor.Exit(m_updateLock);
} }
protected internal void AddPhysicalPrim(int number) protected internal void AddPhysicalPrim(int number)
@ -1554,6 +1561,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="parentPrim"></param> /// <param name="parentPrim"></param>
/// <param name="childPrims"></param> /// <param name="childPrims"></param>
protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds) protected internal void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds)
{
lock (m_updateLock)
{ {
SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId); SceneObjectGroup parentGroup = GetGroupByPrim(parentPrimId);
@ -1608,6 +1617,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
}
/// <summary> /// <summary>
/// Delink a linkset /// Delink a linkset
@ -1619,6 +1629,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
protected internal void DelinkObjects(List<uint> primIds, bool sendEvents) protected internal void DelinkObjects(List<uint> primIds, bool sendEvents)
{
lock (m_updateLock)
{ {
List<SceneObjectPart> childParts = new List<SceneObjectPart>(); List<SceneObjectPart> childParts = new List<SceneObjectPart>();
List<SceneObjectPart> rootParts = new List<SceneObjectPart>(); List<SceneObjectPart> rootParts = new List<SceneObjectPart>();
@ -1725,6 +1737,7 @@ namespace OpenSim.Region.Framework.Scenes
g.ScheduleGroupForFullUpdate(); g.ScheduleGroupForFullUpdate();
} }
} }
}
protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID) protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
{ {