From 6ae426c96ba0bfdad9e884364f5b6be5b4cd61a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 21 May 2013 17:25:06 +0100 Subject: Lock m_UserCache whilst iterating over it in UserManagementModule.GetUserData() to avoid concurrency exceptions --- .../Framework/UserManagement/UserManagementModule.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 6847e57..d99c8eb 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -246,10 +246,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } // search the local cache - foreach (UserData data in m_UserCache.Values) - if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && - (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) - users.Add(data); + lock (m_UserCache) + { + foreach (UserData data in m_UserCache.Values) + { + if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && + (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) + users.Add(data); + } + } AddAdditionalUsers(query, users); -- cgit v1.1