diff options
author | Diva Canto | 2009-10-06 15:39:53 -0700 |
---|---|---|
committer | Diva Canto | 2009-10-06 15:39:53 -0700 |
commit | e992ca025571a891333a57012c2cd4419b6581e5 (patch) | |
tree | a6fd7e9f2e46999c72780bf60d2890e8a9c74fe4 /OpenSim/Region/CoreModules | |
parent | * Change some more default ports to the robust default of 8003 (diff) | |
download | opensim-SC_OLD-e992ca025571a891333a57012c2cd4419b6581e5.zip opensim-SC_OLD-e992ca025571a891333a57012c2cd4419b6581e5.tar.gz opensim-SC_OLD-e992ca025571a891333a57012c2cd4419b6581e5.tar.bz2 opensim-SC_OLD-e992ca025571a891333a57012c2cd4419b6581e5.tar.xz |
Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed.
Diffstat (limited to 'OpenSim/Region/CoreModules')
5 files changed, 62 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..4abad81 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -442,42 +442,46 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
442 | 442 | ||
443 | private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) | 443 | private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) |
444 | { | 444 | { |
445 | ScenePresence returnAgent = null; | 445 | List<Scene> scenes = null; |
446 | lock (m_scenes) | 446 | lock (m_scenes) |
447 | scenes = new List<Scene>(m_scenes.Values); | ||
448 | |||
449 | ScenePresence returnAgent = null; | ||
450 | ScenePresence queryagent = null; | ||
451 | foreach (Scene scene in scenes) | ||
447 | { | 452 | { |
448 | ScenePresence queryagent = null; | 453 | queryagent = scene.GetScenePresence(AgentID); |
449 | foreach (Scene scene in m_scenes.Values) | 454 | if (queryagent != null) |
450 | { | 455 | { |
451 | queryagent = scene.GetScenePresence(AgentID); | 456 | if (!queryagent.IsChildAgent) |
452 | if (queryagent != null) | ||
453 | { | 457 | { |
454 | if (!queryagent.IsChildAgent) | 458 | returnAgent = queryagent; |
455 | { | 459 | break; |
456 | returnAgent = queryagent; | ||
457 | break; | ||
458 | } | ||
459 | } | 460 | } |
460 | } | 461 | } |
461 | } | 462 | } |
463 | |||
462 | return returnAgent; | 464 | return returnAgent; |
463 | } | 465 | } |
464 | 466 | ||
465 | private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) | 467 | private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) |
466 | { | 468 | { |
467 | ScenePresence returnAgent = null; | 469 | List<Scene> scenes = null; |
468 | lock (m_scenes) | 470 | lock (m_scenes) |
471 | scenes = new List<Scene>(m_scenes.Values); | ||
472 | |||
473 | ScenePresence returnAgent = null; | ||
474 | ScenePresence queryagent = null; | ||
475 | foreach (Scene scene in m_scenes.Values) | ||
469 | { | 476 | { |
470 | ScenePresence queryagent = null; | 477 | queryagent = scene.GetScenePresence(AgentID); |
471 | foreach (Scene scene in m_scenes.Values) | 478 | if (queryagent != null) |
472 | { | 479 | { |
473 | queryagent = scene.GetScenePresence(AgentID); | 480 | returnAgent = queryagent; |
474 | if (queryagent != null) | 481 | break; |
475 | { | ||
476 | returnAgent = queryagent; | ||
477 | break; | ||
478 | } | ||
479 | } | 482 | } |
480 | } | 483 | } |
484 | |||
481 | return returnAgent; | 485 | return returnAgent; |
482 | } | 486 | } |
483 | 487 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index ad05bab..42dd7ff 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -290,13 +290,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
290 | 290 | ||
291 | // get the agent. This should work every time, as we just got a packet from it | 291 | // get the agent. This should work every time, as we just got a packet from it |
292 | ScenePresence agent = null; | 292 | ScenePresence agent = null; |
293 | List<Scene> scenes = null; | ||
293 | lock (m_Scenes) | 294 | lock (m_Scenes) |
295 | scenes = new List<Scene>(m_Scenes); | ||
296 | |||
297 | foreach (Scene scene in scenes) | ||
294 | { | 298 | { |
295 | foreach (Scene scene in m_Scenes) | 299 | agent = scene.GetScenePresence(agentID); |
296 | { | 300 | if (agent != null) break; |
297 | agent = scene.GetScenePresence(agentID); | ||
298 | if (agent != null) break; | ||
299 | } | ||
300 | } | 301 | } |
301 | 302 | ||
302 | // just to be paranoid... | 303 | // just to be paranoid... |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..e6e0483 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -111,16 +111,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
111 | 111 | ||
112 | private Scene FindClientScene(UUID agentId) | 112 | private Scene FindClientScene(UUID agentId) |
113 | { | 113 | { |
114 | List<Scene> scenes = null; | ||
114 | lock (m_Scenelist) | 115 | lock (m_Scenelist) |
116 | scenes = new List<Scene>(m_Scenelist); | ||
117 | |||
118 | foreach (Scene scene in scenes) | ||
115 | { | 119 | { |
116 | foreach (Scene scene in m_Scenelist) | 120 | ScenePresence presence = scene.GetScenePresence(agentId); |
121 | if (presence != null) | ||
117 | { | 122 | { |
118 | ScenePresence presence = scene.GetScenePresence(agentId); | 123 | if (!presence.IsChildAgent) |
119 | if (presence != null) | 124 | return scene; |
120 | { | ||
121 | if (!presence.IsChildAgent) | ||
122 | return scene; | ||
123 | } | ||
124 | } | 125 | } |
125 | } | 126 | } |
126 | return null; | 127 | return null; |
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 83f004d..f9f01fe 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -198,19 +198,20 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
198 | 198 | ||
199 | private SceneObjectPart findPrim(UUID objectID, out string ObjectRegionName) | 199 | private SceneObjectPart findPrim(UUID objectID, out string ObjectRegionName) |
200 | { | 200 | { |
201 | List<Scene> scenes = null; | ||
201 | lock (m_Scenes) | 202 | lock (m_Scenes) |
203 | scenes = new List<Scene>(m_Scenes.Values); | ||
204 | |||
205 | foreach (Scene s in scenes) | ||
202 | { | 206 | { |
203 | foreach (Scene s in m_Scenes.Values) | 207 | SceneObjectPart part = s.GetSceneObjectPart(objectID); |
208 | if (part != null) | ||
204 | { | 209 | { |
205 | SceneObjectPart part = s.GetSceneObjectPart(objectID); | 210 | ObjectRegionName = s.RegionInfo.RegionName; |
206 | if (part != null) | 211 | uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); |
207 | { | 212 | uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); |
208 | ObjectRegionName = s.RegionInfo.RegionName; | 213 | ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; |
209 | uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); | 214 | return part; |
210 | uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); | ||
211 | ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; | ||
212 | return part; | ||
213 | } | ||
214 | } | 215 | } |
215 | } | 216 | } |
216 | ObjectRegionName = string.Empty; | 217 | ObjectRegionName = string.Empty; |
@@ -363,6 +364,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
363 | public Email GetNextEmail(UUID objectID, string sender, string subject) | 364 | public Email GetNextEmail(UUID objectID, string sender, string subject) |
364 | { | 365 | { |
365 | List<Email> queue = null; | 366 | List<Email> queue = null; |
367 | List<UUID> removal = new List<UUID>(); | ||
366 | 368 | ||
367 | lock (m_LastGetEmailCall) | 369 | lock (m_LastGetEmailCall) |
368 | { | 370 | { |
@@ -375,7 +377,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
375 | 377 | ||
376 | // Hopefully this isn't too time consuming. If it is, we can always push it into a worker thread. | 378 | // Hopefully this isn't too time consuming. If it is, we can always push it into a worker thread. |
377 | DateTime now = DateTime.Now; | 379 | DateTime now = DateTime.Now; |
378 | List<UUID> removal = new List<UUID>(); | ||
379 | foreach (UUID uuid in m_LastGetEmailCall.Keys) | 380 | foreach (UUID uuid in m_LastGetEmailCall.Keys) |
380 | { | 381 | { |
381 | if ((now - m_LastGetEmailCall[uuid]) > m_QueueTimeout) | 382 | if ((now - m_LastGetEmailCall[uuid]) > m_QueueTimeout) |
@@ -383,15 +384,15 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
383 | removal.Add(uuid); | 384 | removal.Add(uuid); |
384 | } | 385 | } |
385 | } | 386 | } |
387 | } | ||
386 | 388 | ||
387 | foreach (UUID remove in removal) | 389 | foreach (UUID remove in removal) |
388 | { | 390 | { |
391 | lock (m_LastGetEmailCall) | ||
389 | m_LastGetEmailCall.Remove(remove); | 392 | m_LastGetEmailCall.Remove(remove); |
390 | lock (m_MailQueues) | 393 | |
391 | { | 394 | lock (m_MailQueues) |
392 | m_MailQueues.Remove(remove); | 395 | m_MailQueues.Remove(remove); |
393 | } | ||
394 | } | ||
395 | } | 396 | } |
396 | 397 | ||
397 | lock (m_MailQueues) | 398 | lock (m_MailQueues) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index d2b5cb1..0fed1bd 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -187,14 +187,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
187 | LandData newData = data.Copy(); | 187 | LandData newData = data.Copy(); |
188 | newData.LocalID = local_id; | 188 | newData.LocalID = local_id; |
189 | 189 | ||
190 | ILandObject land = null; | ||
190 | lock (m_landList) | 191 | lock (m_landList) |
191 | { | 192 | { |
192 | if (m_landList.ContainsKey(local_id)) | 193 | if (m_landList.ContainsKey(local_id)) |
193 | { | 194 | { |
194 | m_landList[local_id].LandData = newData; | 195 | m_landList[local_id].LandData = newData; |
195 | m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]); | 196 | land = m_landList[local_id]; |
196 | } | 197 | } |
197 | } | 198 | } |
199 | m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, land); | ||
198 | } | 200 | } |
199 | 201 | ||
200 | public bool AllowedForcefulBans | 202 | public bool AllowedForcefulBans |
@@ -504,6 +506,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
504 | /// <param name="local_id">Land.localID of the peice of land to remove.</param> | 506 | /// <param name="local_id">Land.localID of the peice of land to remove.</param> |
505 | public void removeLandObject(int local_id) | 507 | public void removeLandObject(int local_id) |
506 | { | 508 | { |
509 | UUID id = UUID.Zero; | ||
507 | lock (m_landList) | 510 | lock (m_landList) |
508 | { | 511 | { |
509 | for (int x = 0; x < 64; x++) | 512 | for (int x = 0; x < 64; x++) |
@@ -520,9 +523,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
520 | } | 523 | } |
521 | } | 524 | } |
522 | 525 | ||
523 | m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].LandData.GlobalID); | 526 | id = m_landList[local_id].LandData.GlobalID; |
524 | m_landList.Remove(local_id); | 527 | m_landList.Remove(local_id); |
525 | } | 528 | } |
529 | m_scene.EventManager.TriggerLandObjectRemoved(id); | ||
526 | } | 530 | } |
527 | 531 | ||
528 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 532 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |