diff options
author | Diva Canto | 2013-06-11 15:36:27 -0700 |
---|---|---|
committer | Diva Canto | 2013-06-11 15:36:27 -0700 |
commit | b33db917f59ecfcab96a2aec45e19987dbcb44a2 (patch) | |
tree | 8faf5cee1c986f4a5b067a04d7c07216428a2ccf | |
parent | Remove Temporary from use to shortcut asset stores. The Local property (diff) | |
download | opensim-SC_OLD-b33db917f59ecfcab96a2aec45e19987dbcb44a2.zip opensim-SC_OLD-b33db917f59ecfcab96a2aec45e19987dbcb44a2.tar.gz opensim-SC_OLD-b33db917f59ecfcab96a2aec45e19987dbcb44a2.tar.bz2 opensim-SC_OLD-b33db917f59ecfcab96a2aec45e19987dbcb44a2.tar.xz |
Really bad idea to lock m_UserCache for so long in UserManagementModule. Added a special lock object instead, if we really want to avoid concurrent executions of that code.
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 1e70b84..ac21b53 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
56 | 56 | ||
57 | // The cache | 57 | // The cache |
58 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); | 58 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); |
59 | private object m_AddUserLock = new object(); | ||
59 | 60 | ||
60 | #region ISharedRegionModule | 61 | #region ISharedRegionModule |
61 | 62 | ||
@@ -475,9 +476,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
475 | 476 | ||
476 | UserData oldUser; | 477 | UserData oldUser; |
477 | //lock the whole block - prevent concurrent update | 478 | //lock the whole block - prevent concurrent update |
478 | lock (m_UserCache) | 479 | lock (m_AddUserLock) |
479 | { | 480 | { |
480 | m_UserCache.TryGetValue (id, out oldUser); | 481 | lock (m_UserCache) |
482 | m_UserCache.TryGetValue(id, out oldUser); | ||
483 | |||
481 | if (oldUser != null) | 484 | if (oldUser != null) |
482 | { | 485 | { |
483 | if (creatorData == null || creatorData == String.Empty) | 486 | if (creatorData == null || creatorData == String.Empty) |
@@ -488,9 +491,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
488 | 491 | ||
489 | //try update unknown users | 492 | //try update unknown users |
490 | //and creator's home URL's | 493 | //and creator's home URL's |
491 | if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) | 494 | if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL))) |
492 | { | 495 | { |
493 | m_UserCache.Remove (id); | 496 | lock (m_UserCache) |
497 | m_UserCache.Remove(id); | ||
494 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); | 498 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); |
495 | } | 499 | } |
496 | else | 500 | else |
@@ -500,38 +504,38 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
500 | } | 504 | } |
501 | } | 505 | } |
502 | 506 | ||
503 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id); | 507 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); |
504 | 508 | ||
505 | if (account != null) | 509 | if (account != null) |
506 | { | 510 | { |
507 | AddUser (id, account.FirstName, account.LastName); | 511 | AddUser(id, account.FirstName, account.LastName); |
508 | } | 512 | } |
509 | else | 513 | else |
510 | { | 514 | { |
511 | UserData user = new UserData (); | 515 | UserData user = new UserData(); |
512 | user.Id = id; | 516 | user.Id = id; |
513 | 517 | ||
514 | if (creatorData != null && creatorData != string.Empty) | 518 | if (creatorData != null && creatorData != string.Empty) |
515 | { | 519 | { |
516 | //creatorData = <endpoint>;<name> | 520 | //creatorData = <endpoint>;<name> |
517 | 521 | ||
518 | string[] parts = creatorData.Split (';'); | 522 | string[] parts = creatorData.Split(';'); |
519 | if (parts.Length >= 1) | 523 | if (parts.Length >= 1) |
520 | { | 524 | { |
521 | user.HomeURL = parts [0]; | 525 | user.HomeURL = parts[0]; |
522 | try | 526 | try |
523 | { | 527 | { |
524 | Uri uri = new Uri (parts [0]); | 528 | Uri uri = new Uri(parts[0]); |
525 | user.LastName = "@" + uri.Authority; | 529 | user.LastName = "@" + uri.Authority; |
526 | } | 530 | } |
527 | catch (UriFormatException) | 531 | catch (UriFormatException) |
528 | { | 532 | { |
529 | m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]); | 533 | m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); |
530 | user.LastName = "@unknown"; | 534 | user.LastName = "@unknown"; |
531 | } | 535 | } |
532 | } | 536 | } |
533 | if (parts.Length >= 2) | 537 | if (parts.Length >= 2) |
534 | user.FirstName = parts [1].Replace (' ', '.'); | 538 | user.FirstName = parts[1].Replace(' ', '.'); |
535 | } | 539 | } |
536 | else | 540 | else |
537 | { | 541 | { |
@@ -539,7 +543,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
539 | user.LastName = "UserUMMAU"; | 543 | user.LastName = "UserUMMAU"; |
540 | } | 544 | } |
541 | 545 | ||
542 | AddUserInternal (user); | 546 | AddUserInternal(user); |
543 | } | 547 | } |
544 | } | 548 | } |
545 | } | 549 | } |