diff options
author | UbitUmarov | 2016-08-19 00:14:46 +0100 |
---|---|---|
committer | UbitUmarov | 2016-08-19 00:14:46 +0100 |
commit | c53d74274d1fa9e76621206185ee4e1ff3c57f16 (patch) | |
tree | 8ead5e973ec0a9b2e617eec009222fa15d7e3ed7 /OpenSim/Region/CoreModules/ServiceConnectorsOut | |
parent | avoid NULL refs (diff) | |
download | opensim-SC_OLD-c53d74274d1fa9e76621206185ee4e1ff3c57f16.zip opensim-SC_OLD-c53d74274d1fa9e76621206185ee4e1ff3c57f16.tar.gz opensim-SC_OLD-c53d74274d1fa9e76621206185ee4e1ff3c57f16.tar.bz2 opensim-SC_OLD-c53d74274d1fa9e76621206185ee4e1ff3c57f16.tar.xz |
missed another UserAccounts cache, add a few locks
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
2 files changed, 69 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 1bb4704..3127199 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -153,12 +153,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
153 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | 153 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) |
154 | { | 154 | { |
155 | bool inCache = false; | 155 | bool inCache = false; |
156 | UserAccount account = m_Cache.Get(userID, out inCache); | 156 | UserAccount account; |
157 | lock(m_Cache) | ||
158 | account = m_Cache.Get(userID, out inCache); | ||
157 | if (inCache) | 159 | if (inCache) |
158 | return account; | 160 | return account; |
159 | 161 | ||
160 | account = UserAccountService.GetUserAccount(scopeID, userID); | 162 | account = UserAccountService.GetUserAccount(scopeID, userID); |
161 | m_Cache.Cache(userID, account); | 163 | lock(m_Cache) |
164 | m_Cache.Cache(userID, account); | ||
162 | 165 | ||
163 | return account; | 166 | return account; |
164 | } | 167 | } |
@@ -166,13 +169,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
166 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 169 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
167 | { | 170 | { |
168 | bool inCache = false; | 171 | bool inCache = false; |
169 | UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); | 172 | UserAccount account; |
173 | lock(m_Cache) | ||
174 | account = m_Cache.Get(firstName + " " + lastName, out inCache); | ||
170 | if (inCache) | 175 | if (inCache) |
171 | return account; | 176 | return account; |
172 | 177 | ||
173 | account = UserAccountService.GetUserAccount(scopeID, firstName, lastName); | 178 | account = UserAccountService.GetUserAccount(scopeID, firstName, lastName); |
174 | if (account != null) | 179 | if (account != null) |
175 | m_Cache.Cache(account.PrincipalID, account); | 180 | lock(m_Cache) |
181 | m_Cache.Cache(account.PrincipalID, account); | ||
176 | 182 | ||
177 | return account; | 183 | return account; |
178 | } | 184 | } |
@@ -184,9 +190,42 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
184 | 190 | ||
185 | public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs) | 191 | public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs) |
186 | { | 192 | { |
187 | return UserAccountService.GetUserAccounts(scopeID, IDs); | 193 | List<UserAccount> ret = new List<UserAccount>(); |
188 | } | 194 | List<string> missing = new List<string>(); |
195 | |||
196 | // still another cache.. | ||
197 | bool inCache = false; | ||
198 | UUID uuid = UUID.Zero; | ||
199 | UserAccount account; | ||
200 | foreach(string id in IDs) | ||
201 | { | ||
202 | if(UUID.TryParse(id, out uuid)) | ||
203 | { | ||
204 | lock(m_Cache) | ||
205 | account = m_Cache.Get(uuid, out inCache); | ||
206 | if (inCache) | ||
207 | ret.Add(account); | ||
208 | else | ||
209 | missing.Add(id); | ||
210 | } | ||
211 | } | ||
189 | 212 | ||
213 | if(missing.Count == 0) | ||
214 | return ret; | ||
215 | |||
216 | List<UserAccount> ext = UserAccountService.GetUserAccounts(scopeID, missing); | ||
217 | if(ext != null && ext.Count > 0) | ||
218 | { | ||
219 | ret.AddRange(ext); | ||
220 | foreach(UserAccount acc in ext) | ||
221 | { | ||
222 | if(acc != null) | ||
223 | lock(m_Cache) | ||
224 | m_Cache.Cache(acc.PrincipalID, acc); | ||
225 | } | ||
226 | } | ||
227 | return ret; | ||
228 | } | ||
190 | 229 | ||
191 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query) | 230 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query) |
192 | { | 231 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 90c90d6..eead05d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -128,7 +128,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
128 | // flags, title, etc. And country, don't forget country! | 128 | // flags, title, etc. And country, don't forget country! |
129 | private void OnNewClient(IClientAPI client) | 129 | private void OnNewClient(IClientAPI client) |
130 | { | 130 | { |
131 | m_Cache.Remove(client.Name); | 131 | lock(m_Cache) |
132 | m_Cache.Remove(client.Name); | ||
132 | } | 133 | } |
133 | 134 | ||
134 | #region Overwritten methods from IUserAccountService | 135 | #region Overwritten methods from IUserAccountService |
@@ -136,12 +137,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
136 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) | 137 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) |
137 | { | 138 | { |
138 | bool inCache = false; | 139 | bool inCache = false; |
139 | UserAccount account = m_Cache.Get(userID, out inCache); | 140 | UserAccount account; |
141 | lock(m_Cache) | ||
142 | account = m_Cache.Get(userID, out inCache); | ||
140 | if (inCache) | 143 | if (inCache) |
141 | return account; | 144 | return account; |
142 | 145 | ||
143 | account = base.GetUserAccount(scopeID, userID); | 146 | account = base.GetUserAccount(scopeID, userID); |
144 | m_Cache.Cache(userID, account); | 147 | lock(m_Cache) |
148 | if(account != null) | ||
149 | m_Cache.Cache(userID, account); | ||
145 | 150 | ||
146 | return account; | 151 | return account; |
147 | } | 152 | } |
@@ -149,13 +154,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
149 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 154 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
150 | { | 155 | { |
151 | bool inCache = false; | 156 | bool inCache = false; |
152 | UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); | 157 | UserAccount account; |
158 | lock(m_Cache) | ||
159 | account = m_Cache.Get(firstName + " " + lastName, out inCache); | ||
153 | if (inCache) | 160 | if (inCache) |
154 | return account; | 161 | return account; |
155 | 162 | ||
156 | account = base.GetUserAccount(scopeID, firstName, lastName); | 163 | account = base.GetUserAccount(scopeID, firstName, lastName); |
157 | if (account != null) | 164 | if (account != null) |
158 | m_Cache.Cache(account.PrincipalID, account); | 165 | lock(m_Cache) |
166 | m_Cache.Cache(account.PrincipalID, account); | ||
159 | 167 | ||
160 | return account; | 168 | return account; |
161 | } | 169 | } |
@@ -173,7 +181,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
173 | { | 181 | { |
174 | if(UUID.TryParse(id, out uuid)) | 182 | if(UUID.TryParse(id, out uuid)) |
175 | { | 183 | { |
176 | account = m_Cache.Get(uuid, out inCache); | 184 | lock(m_Cache) |
185 | account = m_Cache.Get(uuid, out inCache); | ||
177 | if (inCache) | 186 | if (inCache) |
178 | accs.Add(account); | 187 | accs.Add(account); |
179 | else | 188 | else |
@@ -184,8 +193,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
184 | if(missing.Count > 0) | 193 | if(missing.Count > 0) |
185 | { | 194 | { |
186 | List<UserAccount> ext = base.GetUserAccounts(scopeID, missing); | 195 | List<UserAccount> ext = base.GetUserAccounts(scopeID, missing); |
187 | if(ext != null) | 196 | if(ext != null && ext.Count >0 ) |
197 | { | ||
188 | accs.AddRange(ext); | 198 | accs.AddRange(ext); |
199 | foreach(UserAccount acc in ext) | ||
200 | { | ||
201 | if(acc != null) | ||
202 | lock(m_Cache) | ||
203 | m_Cache.Cache(acc.PrincipalID, acc); | ||
204 | } | ||
205 | } | ||
189 | } | 206 | } |
190 | 207 | ||
191 | return accs; | 208 | return accs; |