Changed locks to prevent deadlocks (especially during multi-region Load OAR)

user_profiles
Oren Hurvitz 2012-08-09 14:51:05 +03:00 committed by Justin Clark-Casey (justincc)
parent d2f4ca0dfe
commit 9784e4e07d
3 changed files with 61 additions and 39 deletions

View File

@ -603,15 +603,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <param name="uuid"></param> /// <param name="uuid"></param>
/// <returns></returns> /// <returns></returns>
private bool ResolveUserUuid(Scene scene, UUID uuid) private bool ResolveUserUuid(Scene scene, UUID uuid)
{
lock (m_validUserUuids)
{ {
if (!m_validUserUuids.ContainsKey(uuid)) if (!m_validUserUuids.ContainsKey(uuid))
{ {
// Note: we call GetUserAccount() inside the lock because this UserID is likely
// to occur many times, and we only want to query the users service once.
UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid); UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid);
m_validUserUuids.Add(uuid, account != null); m_validUserUuids.Add(uuid, account != null);
} }
return m_validUserUuids[uuid]; return m_validUserUuids[uuid];
} }
}
/// <summary> /// <summary>
/// Look up the given group id to check whether it's one that is valid for this grid. /// Look up the given group id to check whether it's one that is valid for this grid.
@ -623,20 +628,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (uuid == UUID.Zero) if (uuid == UUID.Zero)
return true; // this means the object has no group return true; // this means the object has no group
lock (m_validGroupUuids)
{
if (!m_validGroupUuids.ContainsKey(uuid)) if (!m_validGroupUuids.ContainsKey(uuid))
{ {
bool exists; bool exists;
if (m_groupsModule == null) if (m_groupsModule == null)
{
exists = false; exists = false;
}
else else
{
// Note: we call GetGroupRecord() inside the lock because this GroupID is likely
// to occur many times, and we only want to query the groups service once.
exists = (m_groupsModule.GetGroupRecord(uuid) != null); exists = (m_groupsModule.GetGroupRecord(uuid) != null);
}
m_validGroupUuids.Add(uuid, exists); m_validGroupUuids.Add(uuid, exists);
} }
return m_validGroupUuids[uuid]; return m_validGroupUuids[uuid];
} }
}
/// Load an asset /// Load an asset
/// </summary> /// </summary>

View File

@ -287,14 +287,15 @@ namespace OpenSim.Region.CoreModules.World.Land
LandData newData = data.Copy(); LandData newData = data.Copy();
newData.LocalID = local_id; newData.LocalID = local_id;
ILandObject land;
lock (m_landList) lock (m_landList)
{ {
if (m_landList.ContainsKey(local_id)) if (m_landList.TryGetValue(local_id, out land))
{ land.LandData = newData;
m_landList[local_id].LandData = newData;
m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]);
}
} }
if (land != null)
m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, land);
} }
public bool AllowedForcefulBans public bool AllowedForcefulBans
@ -650,6 +651,7 @@ namespace OpenSim.Region.CoreModules.World.Land
/// <param name="local_id">Land.localID of the peice of land to remove.</param> /// <param name="local_id">Land.localID of the peice of land to remove.</param>
public void removeLandObject(int local_id) public void removeLandObject(int local_id)
{ {
ILandObject land;
lock (m_landList) lock (m_landList)
{ {
for (int x = 0; x < 64; x++) for (int x = 0; x < 64; x++)
@ -666,9 +668,11 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
} }
m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].LandData.GlobalID); land = m_landList[local_id];
m_landList.Remove(local_id); m_landList.Remove(local_id);
} }
m_scene.EventManager.TriggerLandObjectRemoved(land.LandData.GlobalID);
} }
/// <summary> /// <summary>
@ -676,22 +680,28 @@ namespace OpenSim.Region.CoreModules.World.Land
/// </summary> /// </summary>
public void Clear(bool setupDefaultParcel) public void Clear(bool setupDefaultParcel)
{ {
List<ILandObject> parcels;
lock (m_landList) lock (m_landList)
{ {
foreach (ILandObject lo in m_landList.Values) parcels = new List<ILandObject>(m_landList.Values);
}
foreach (ILandObject lo in parcels)
{ {
//m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
} }
lock (m_landList)
{
m_landList.Clear(); m_landList.Clear();
ResetSimLandObjects(); ResetSimLandObjects();
}
if (setupDefaultParcel) if (setupDefaultParcel)
CreateDefaultParcel(); CreateDefaultParcel();
} }
}
private void performFinalLandJoin(ILandObject master, ILandObject slave) private void performFinalLandJoin(ILandObject master, ILandObject slave)
{ {
@ -1457,13 +1467,10 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
public void EventManagerOnNoLandDataFromStorage() public void EventManagerOnNoLandDataFromStorage()
{
lock (m_landList)
{ {
ResetSimLandObjects(); ResetSimLandObjects();
CreateDefaultParcel(); CreateDefaultParcel();
} }
}
#endregion #endregion

View File

@ -490,12 +490,15 @@ namespace OpenSim.Region.CoreModules.World.Land
m_Scene.ForEachSOG(AddObject); m_Scene.ForEachSOG(AddObject);
lock (m_PrimCounts)
{
List<UUID> primcountKeys = new List<UUID>(m_PrimCounts.Keys); List<UUID> primcountKeys = new List<UUID>(m_PrimCounts.Keys);
foreach (UUID k in primcountKeys) foreach (UUID k in primcountKeys)
{ {
if (!m_OwnerMap.ContainsKey(k)) if (!m_OwnerMap.ContainsKey(k))
m_PrimCounts.Remove(k); m_PrimCounts.Remove(k);
} }
}
m_Tainted = false; m_Tainted = false;
} }