diff options
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.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 55 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneGraph.cs | 15 |
2 files changed, 43 insertions, 27 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index fad90fa..9c3aa96 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -3175,13 +3175,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
3175 | return; | 3175 | return; |
3176 | } | 3176 | } |
3177 | 3177 | ||
3178 | ScenePresence sp = null; | ||
3178 | lock (m_scenePresences) | 3179 | lock (m_scenePresences) |
3179 | { | 3180 | { |
3180 | if (m_scenePresences.ContainsKey(remoteClient.AgentId)) | 3181 | if (m_scenePresences.ContainsKey(remoteClient.AgentId)) |
3181 | { | 3182 | sp = m_scenePresences[remoteClient.AgentId]; |
3182 | m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], info.RegionHandle, | 3183 | } |
3183 | position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); | 3184 | if (sp != null) |
3184 | } | 3185 | { |
3186 | m_sceneGridService.RequestTeleportToLocation(sp, info.RegionHandle, | ||
3187 | position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); | ||
3185 | } | 3188 | } |
3186 | } | 3189 | } |
3187 | 3190 | ||
@@ -3417,36 +3420,40 @@ namespace OpenSim.Region.Environment.Scenes | |||
3417 | public void handleRequestGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godLike, | 3420 | public void handleRequestGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godLike, |
3418 | IClientAPI controllingClient) | 3421 | IClientAPI controllingClient) |
3419 | { | 3422 | { |
3423 | ScenePresence sp = null; | ||
3424 | |||
3420 | lock (m_scenePresences) | 3425 | lock (m_scenePresences) |
3421 | { | 3426 | { |
3422 | // User needs to be logged into this sim | 3427 | // User needs to be logged into this sim |
3423 | if (m_scenePresences.ContainsKey(agentID)) | 3428 | m_scenePresences.TryGetValue(agentID, out sp); |
3429 | } | ||
3430 | |||
3431 | if (sp != null) | ||
3432 | { | ||
3433 | if (godLike == false) | ||
3424 | { | 3434 | { |
3425 | if (godLike == false) | 3435 | sp.GrantGodlikePowers(agentID, sessionID, token, godLike); |
3426 | { | 3436 | return; |
3427 | m_scenePresences[agentID].GrantGodlikePowers(agentID, sessionID, token, godLike); | 3437 | } |
3428 | return; | ||
3429 | } | ||
3430 | 3438 | ||
3431 | // First check that this is the sim owner | 3439 | // First check that this is the sim owner |
3432 | if (Permissions.IsGod(agentID)) | 3440 | if (Permissions.IsGod(agentID)) |
3441 | { | ||
3442 | // Next we check for spoofing..... | ||
3443 | UUID testSessionID = sp.ControllingClient.SessionId; | ||
3444 | if (sessionID == testSessionID) | ||
3433 | { | 3445 | { |
3434 | // Next we check for spoofing..... | 3446 | if (sessionID == controllingClient.SessionId) |
3435 | UUID testSessionID = m_scenePresences[agentID].ControllingClient.SessionId; | ||
3436 | if (sessionID == testSessionID) | ||
3437 | { | 3447 | { |
3438 | if (sessionID == controllingClient.SessionId) | 3448 | //m_log.Info("godlike: " + godLike.ToString()); |
3439 | { | 3449 | sp.GrantGodlikePowers(agentID, testSessionID, token, godLike); |
3440 | //m_log.Info("godlike: " + godLike.ToString()); | ||
3441 | m_scenePresences[agentID].GrantGodlikePowers(agentID, testSessionID, token, godLike); | ||
3442 | } | ||
3443 | } | 3450 | } |
3444 | } | 3451 | } |
3445 | else | ||
3446 | { | ||
3447 | m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); | ||
3448 | } | ||
3449 | } | 3452 | } |
3453 | else | ||
3454 | { | ||
3455 | m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); | ||
3456 | } | ||
3450 | } | 3457 | } |
3451 | } | 3458 | } |
3452 | 3459 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneGraph.cs b/OpenSim/Region/Environment/Scenes/SceneGraph.cs index be2fb46..940aee6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Environment/Scenes/SceneGraph.cs | |||
@@ -774,7 +774,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
774 | /// <returns></returns> | 774 | /// <returns></returns> |
775 | protected internal List<ScenePresence> GetScenePresences() | 775 | protected internal List<ScenePresence> GetScenePresences() |
776 | { | 776 | { |
777 | return new List<ScenePresence>(ScenePresences.Values); | 777 | lock (ScenePresences) |
778 | { | ||
779 | return new List<ScenePresence>(ScenePresences.Values); | ||
780 | } | ||
778 | } | 781 | } |
779 | 782 | ||
780 | protected internal List<ScenePresence> GetAvatars() | 783 | protected internal List<ScenePresence> GetAvatars() |
@@ -1085,12 +1088,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
1085 | 1088 | ||
1086 | protected internal void ForEachClient(Action<IClientAPI> action) | 1089 | protected internal void ForEachClient(Action<IClientAPI> action) |
1087 | { | 1090 | { |
1088 | lock (ScenePresences) | 1091 | List<ScenePresence> splist = GetScenePresences(); |
1092 | foreach (ScenePresence presence in splist) | ||
1089 | { | 1093 | { |
1090 | foreach (ScenePresence presence in ScenePresences.Values) | 1094 | try |
1091 | { | 1095 | { |
1092 | action(presence.ControllingClient); | 1096 | action(presence.ControllingClient); |
1093 | } | 1097 | } |
1098 | catch (Exception e) | ||
1099 | { | ||
1100 | // Catch it and move on. This includes situations where splist has inconsistent info | ||
1101 | m_log.WarnFormat("[SCENE]: Problem processing action in ForEachClient: ", e.Message); | ||
1102 | } | ||
1094 | } | 1103 | } |
1095 | } | 1104 | } |
1096 | 1105 | ||