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

@ -604,13 +604,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <returns></returns> /// <returns></returns>
private bool ResolveUserUuid(Scene scene, UUID uuid) private bool ResolveUserUuid(Scene scene, UUID uuid)
{ {
if (!m_validUserUuids.ContainsKey(uuid)) lock (m_validUserUuids)
{ {
UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid); if (!m_validUserUuids.ContainsKey(uuid))
m_validUserUuids.Add(uuid, account != null); {
} // 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);
m_validUserUuids.Add(uuid, account != null);
}
return m_validUserUuids[uuid]; return m_validUserUuids[uuid];
}
} }
/// <summary> /// <summary>
@ -623,19 +628,26 @@ 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
if (!m_validGroupUuids.ContainsKey(uuid)) lock (m_validGroupUuids)
{ {
bool exists; if (!m_validGroupUuids.ContainsKey(uuid))
{
bool exists;
if (m_groupsModule == null)
{
exists = false;
}
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);
}
m_validGroupUuids.Add(uuid, exists);
}
if (m_groupsModule == null) return m_validGroupUuids[uuid];
exists = false;
else
exists = (m_groupsModule.GetGroupRecord(uuid) != null);
m_validGroupUuids.Add(uuid, exists);
} }
return m_validGroupUuids[uuid];
} }
/// Load an asset /// Load an asset

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,21 +680,27 @@ 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);
{ }
//m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
}
foreach (ILandObject lo in parcels)
{
//m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
}
lock (m_landList)
{
m_landList.Clear(); m_landList.Clear();
ResetSimLandObjects(); ResetSimLandObjects();
if (setupDefaultParcel)
CreateDefaultParcel();
} }
if (setupDefaultParcel)
CreateDefaultParcel();
} }
private void performFinalLandJoin(ILandObject master, ILandObject slave) private void performFinalLandJoin(ILandObject master, ILandObject slave)
@ -1458,11 +1468,8 @@ namespace OpenSim.Region.CoreModules.World.Land
public void EventManagerOnNoLandDataFromStorage() public void EventManagerOnNoLandDataFromStorage()
{ {
lock (m_landList) ResetSimLandObjects();
{ CreateDefaultParcel();
ResetSimLandObjects();
CreateDefaultParcel();
}
} }
#endregion #endregion

View File

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