aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs75
1 files changed, 54 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index b4785f4..c16e92e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -1,4 +1,31 @@
1using System; 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
2using System.Collections.Generic; 29using System.Collections.Generic;
3using System.Reflection; 30using System.Reflection;
4 31
@@ -12,21 +39,23 @@ using log4net;
12 39
13namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
14{ 41{
15 public abstract class InventoryCache 42 public class InventoryCache
16 { 43 {
17 private static readonly ILog m_log = 44 private static readonly ILog m_log =
18 LogManager.GetLogger( 45 LogManager.GetLogger(
19 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
20 47
48 protected BaseInventoryConnector m_Connector;
21 protected List<Scene> m_Scenes; 49 protected List<Scene> m_Scenes;
22 50
23 // The cache proper 51 // The cache proper
24 protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache; 52 protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache;
25 53
26 protected virtual void Init(IConfigSource source) 54 public virtual void Init(IConfigSource source, BaseInventoryConnector connector)
27 { 55 {
28 m_Scenes = new List<Scene>(); 56 m_Scenes = new List<Scene>();
29 m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>(); 57 m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>();
58 m_Connector = connector;
30 } 59 }
31 60
32 public virtual void AddRegion(Scene scene) 61 public virtual void AddRegion(Scene scene)
@@ -59,9 +88,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
59 } 88 }
60 89
61 // If not, go get them and place them in the cache 90 // If not, go get them and place them in the cache
62 Dictionary<AssetType, InventoryFolderBase> folders = GetSystemFolders(presence.UUID); 91 Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(presence.UUID);
63 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, fetched system folders for {0} {1}: count {2}", 92 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}",
64 presence.Firstname, presence.Lastname, folders.Count); 93 presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count);
65 if (folders.Count > 0) 94 if (folders.Count > 0)
66 lock (m_InventoryCache) 95 lock (m_InventoryCache)
67 m_InventoryCache.Add(presence.UUID, folders); 96 m_InventoryCache.Add(presence.UUID, folders);
@@ -69,28 +98,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
69 98
70 void OnClientClosed(UUID clientID, Scene scene) 99 void OnClientClosed(UUID clientID, Scene scene)
71 { 100 {
72 ScenePresence sp = null; 101 if (m_InventoryCache.ContainsKey(clientID)) // if it's still in cache
73 foreach (Scene s in m_Scenes)
74 { 102 {
75 s.TryGetAvatar(clientID, out sp); 103 ScenePresence sp = null;
76 if ((sp != null) && !sp.IsChildAgent) 104 foreach (Scene s in m_Scenes)
77 { 105 {
78 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", 106 s.TryGetAvatar(clientID, out sp);
79 scene.RegionInfo.RegionName, clientID); 107 if ((sp != null) && !sp.IsChildAgent && (s != scene))
80 return; 108 {
109 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache",
110 scene.RegionInfo.RegionName, clientID);
111 return;
112 }
81 } 113 }
82 }
83 114
84 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", 115 // Drop system folders
85 scene.RegionInfo.RegionName, clientID); 116 lock (m_InventoryCache)
86 // Drop system folders 117 if (m_InventoryCache.ContainsKey(clientID))
87 lock (m_InventoryCache) 118 {
88 if (m_InventoryCache.ContainsKey(clientID)) 119 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders",
89 m_InventoryCache.Remove(clientID); 120 scene.RegionInfo.RegionName, clientID);
90 121
122 m_InventoryCache.Remove(clientID);
123 }
124 }
91 } 125 }
92 126
93 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
94 127
95 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 128 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
96 { 129 {