Eased the locking times of ScenePresences. No locks were removed, just the locking periods changed.

* Added an additional lock in GetScenePresences()
* Changed ForEachClient to use GetScenePresences() instead of the main ScenePresences dictionary, so that there is no need to lock.
0.6.2-post-fixes
diva 2009-01-15 23:37:49 +00:00
parent d1456554f2
commit e80dcfa9f6
2 changed files with 44 additions and 28 deletions

View File

@ -3175,13 +3175,16 @@ namespace OpenSim.Region.Environment.Scenes
return; return;
} }
ScenePresence sp = null;
lock (m_scenePresences) lock (m_scenePresences)
{ {
if (m_scenePresences.ContainsKey(remoteClient.AgentId)) if (m_scenePresences.ContainsKey(remoteClient.AgentId))
{ sp = m_scenePresences[remoteClient.AgentId];
m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], info.RegionHandle,
position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
} }
if (sp != null)
{
m_sceneGridService.RequestTeleportToLocation(sp, info.RegionHandle,
position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
} }
} }
@ -3417,14 +3420,19 @@ namespace OpenSim.Region.Environment.Scenes
public void handleRequestGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godLike, public void handleRequestGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godLike,
IClientAPI controllingClient) IClientAPI controllingClient)
{ {
ScenePresence sp = null;
lock (m_scenePresences) lock (m_scenePresences)
{ {
// User needs to be logged into this sim // User needs to be logged into this sim
if (m_scenePresences.ContainsKey(agentID)) m_scenePresences.TryGetValue(agentID, out sp);
}
if (sp != null)
{ {
if (godLike == false) if (godLike == false)
{ {
m_scenePresences[agentID].GrantGodlikePowers(agentID, sessionID, token, godLike); sp.GrantGodlikePowers(agentID, sessionID, token, godLike);
return; return;
} }
@ -3432,13 +3440,13 @@ namespace OpenSim.Region.Environment.Scenes
if (Permissions.IsGod(agentID)) if (Permissions.IsGod(agentID))
{ {
// Next we check for spoofing..... // Next we check for spoofing.....
UUID testSessionID = m_scenePresences[agentID].ControllingClient.SessionId; UUID testSessionID = sp.ControllingClient.SessionId;
if (sessionID == testSessionID) if (sessionID == testSessionID)
{ {
if (sessionID == controllingClient.SessionId) if (sessionID == controllingClient.SessionId)
{ {
//m_log.Info("godlike: " + godLike.ToString()); //m_log.Info("godlike: " + godLike.ToString());
m_scenePresences[agentID].GrantGodlikePowers(agentID, testSessionID, token, godLike); sp.GrantGodlikePowers(agentID, testSessionID, token, godLike);
} }
} }
} }
@ -3448,7 +3456,6 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
}
/// <summary> /// <summary>
/// Kicks User specified from the simulator. This logs them off of the grid /// Kicks User specified from the simulator. This logs them off of the grid

View File

@ -773,9 +773,12 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
protected internal List<ScenePresence> GetScenePresences() protected internal List<ScenePresence> GetScenePresences()
{
lock (ScenePresences)
{ {
return new List<ScenePresence>(ScenePresences.Values); return new List<ScenePresence>(ScenePresences.Values);
} }
}
protected internal List<ScenePresence> GetAvatars() protected internal List<ScenePresence> GetAvatars()
{ {
@ -1085,12 +1088,18 @@ namespace OpenSim.Region.Environment.Scenes
protected internal void ForEachClient(Action<IClientAPI> action) protected internal void ForEachClient(Action<IClientAPI> action)
{ {
lock (ScenePresences) List<ScenePresence> splist = GetScenePresences();
foreach (ScenePresence presence in splist)
{ {
foreach (ScenePresence presence in ScenePresences.Values) try
{ {
action(presence.ControllingClient); action(presence.ControllingClient);
} }
catch (Exception e)
{
// Catch it and move on. This includes situations where splist has inconsistent info
m_log.WarnFormat("[SCENE]: Problem processing action in ForEachClient: ", e.Message);
}
} }
} }