diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
4 files changed, 126 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 863560b..c48186f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -203,21 +203,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
203 | 203 | ||
204 | void OnClientClosed(UUID clientID, Scene scene) | 204 | void OnClientClosed(UUID clientID, Scene scene) |
205 | { | 205 | { |
206 | if (m_InventoryURLs.ContainsKey(clientID)) // if it's in cache | 206 | ScenePresence sp = null; |
207 | foreach (Scene s in m_Scenes) | ||
207 | { | 208 | { |
208 | ScenePresence sp = null; | 209 | s.TryGetScenePresence(clientID, out sp); |
209 | foreach (Scene s in m_Scenes) | 210 | if ((sp != null) && !sp.IsChildAgent && (s != scene)) |
210 | { | 211 | { |
211 | s.TryGetScenePresence(clientID, out sp); | 212 | m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache", |
212 | if ((sp != null) && !sp.IsChildAgent && (s != scene)) | ||
213 | { | ||
214 | m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache", | ||
215 | scene.RegionInfo.RegionName, clientID); | 213 | scene.RegionInfo.RegionName, clientID); |
216 | return; | 214 | return; |
217 | } | ||
218 | } | 215 | } |
219 | DropInventoryServiceURL(clientID); | ||
220 | } | 216 | } |
217 | |||
218 | if (m_InventoryURLs.ContainsKey(clientID)) // if it's in cache | ||
219 | DropInventoryServiceURL(clientID); | ||
220 | |||
221 | m_Cache.RemoveAll(clientID); | ||
221 | } | 222 | } |
222 | 223 | ||
223 | /// <summary> | 224 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 3195e6b..f7ef2ea 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -38,12 +38,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
38 | /// </summary> | 38 | /// </summary> |
39 | public class InventoryCache | 39 | public class InventoryCache |
40 | { | 40 | { |
41 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour | 41 | private const double CACHE_EXPIRATION_SECONDS = 60.0; // 1 minute |
42 | 42 | ||
43 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); | 43 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); |
44 | private static ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>>(); | 44 | private static ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>>(); |
45 | private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); | 45 | private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); |
46 | 46 | ||
47 | |||
48 | public void RemoveAll(UUID userID) | ||
49 | { | ||
50 | if(m_RootFolders.Contains(userID)) | ||
51 | m_RootFolders.Remove(userID); | ||
52 | if(m_FolderTypes.Contains(userID)) | ||
53 | m_FolderTypes.Remove(userID); | ||
54 | if(m_Inventories.Contains(userID)) | ||
55 | m_Inventories.Remove(userID); | ||
56 | } | ||
57 | |||
47 | public void Cache(UUID userID, InventoryFolderBase root) | 58 | public void Cache(UUID userID, InventoryFolderBase root) |
48 | { | 59 | { |
49 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); | 60 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cf9a7b4..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 | } |
@@ -182,6 +188,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
182 | return UserAccountService.GetUserAccount(scopeID, Email); | 188 | return UserAccountService.GetUserAccount(scopeID, Email); |
183 | } | 189 | } |
184 | 190 | ||
191 | public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs) | ||
192 | { | ||
193 | List<UserAccount> ret = new List<UserAccount>(); | ||
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 | } | ||
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 | } | ||
229 | |||
185 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query) | 230 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query) |
186 | { | 231 | { |
187 | return null; | 232 | return null; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index afbba30..eead05d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
29 | using Nini.Config; | 31 | using Nini.Config; |
30 | using log4net; | 32 | using log4net; |
31 | using Mono.Addins; | 33 | using Mono.Addins; |
@@ -126,7 +128,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
126 | // flags, title, etc. And country, don't forget country! | 128 | // flags, title, etc. And country, don't forget country! |
127 | private void OnNewClient(IClientAPI client) | 129 | private void OnNewClient(IClientAPI client) |
128 | { | 130 | { |
129 | m_Cache.Remove(client.Name); | 131 | lock(m_Cache) |
132 | m_Cache.Remove(client.Name); | ||
130 | } | 133 | } |
131 | 134 | ||
132 | #region Overwritten methods from IUserAccountService | 135 | #region Overwritten methods from IUserAccountService |
@@ -134,12 +137,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
134 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) | 137 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) |
135 | { | 138 | { |
136 | bool inCache = false; | 139 | bool inCache = false; |
137 | UserAccount account = m_Cache.Get(userID, out inCache); | 140 | UserAccount account; |
141 | lock(m_Cache) | ||
142 | account = m_Cache.Get(userID, out inCache); | ||
138 | if (inCache) | 143 | if (inCache) |
139 | return account; | 144 | return account; |
140 | 145 | ||
141 | account = base.GetUserAccount(scopeID, userID); | 146 | account = base.GetUserAccount(scopeID, userID); |
142 | m_Cache.Cache(userID, account); | 147 | lock(m_Cache) |
148 | if(account != null) | ||
149 | m_Cache.Cache(userID, account); | ||
143 | 150 | ||
144 | return account; | 151 | return account; |
145 | } | 152 | } |
@@ -147,17 +154,60 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
147 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 154 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
148 | { | 155 | { |
149 | bool inCache = false; | 156 | bool inCache = false; |
150 | 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); | ||
151 | if (inCache) | 160 | if (inCache) |
152 | return account; | 161 | return account; |
153 | 162 | ||
154 | account = base.GetUserAccount(scopeID, firstName, lastName); | 163 | account = base.GetUserAccount(scopeID, firstName, lastName); |
155 | if (account != null) | 164 | if (account != null) |
156 | m_Cache.Cache(account.PrincipalID, account); | 165 | lock(m_Cache) |
166 | m_Cache.Cache(account.PrincipalID, account); | ||
157 | 167 | ||
158 | return account; | 168 | return account; |
159 | } | 169 | } |
160 | 170 | ||
171 | public override List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs) | ||
172 | { | ||
173 | List<UserAccount> accs = new List<UserAccount>(); | ||
174 | List<string> missing = new List<string>(); | ||
175 | |||
176 | UUID uuid = UUID.Zero; | ||
177 | UserAccount account; | ||
178 | bool inCache = false; | ||
179 | |||
180 | foreach(string id in IDs) | ||
181 | { | ||
182 | if(UUID.TryParse(id, out uuid)) | ||
183 | { | ||
184 | lock(m_Cache) | ||
185 | account = m_Cache.Get(uuid, out inCache); | ||
186 | if (inCache) | ||
187 | accs.Add(account); | ||
188 | else | ||
189 | missing.Add(id); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | if(missing.Count > 0) | ||
194 | { | ||
195 | List<UserAccount> ext = base.GetUserAccounts(scopeID, missing); | ||
196 | if(ext != null && ext.Count >0 ) | ||
197 | { | ||
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 | } | ||
206 | } | ||
207 | |||
208 | return accs; | ||
209 | } | ||
210 | |||
161 | public override bool StoreUserAccount(UserAccount data) | 211 | public override bool StoreUserAccount(UserAccount data) |
162 | { | 212 | { |
163 | // This remote connector refuses to serve this method | 213 | // This remote connector refuses to serve this method |