aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2013-06-18 01:50:08 +0100
committerMelanie2013-06-18 01:50:08 +0100
commit56f4adeb60622aaec687f3a6699a03c964f59d5b (patch)
tree0ba2fe5ffd3984b41fab05b56361fda507b2a34a /OpenSim/Region/CoreModules
parentMerge branch 'master' into careminster (diff)
parentcorrect method doc for llRot2Axis() (diff)
downloadopensim-SC-56f4adeb60622aaec687f3a6699a03c964f59d5b.zip
opensim-SC-56f4adeb60622aaec687f3a6699a03c964f59d5b.tar.gz
opensim-SC-56f4adeb60622aaec687f3a6699a03c964f59d5b.tar.bz2
opensim-SC-56f4adeb60622aaec687f3a6699a03c964f59d5b.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs OpenSim/Services/LLLoginService/LLLoginResponse.cs OpenSim/Services/LLLoginService/LLLoginService.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs66
2 files changed, 74 insertions, 38 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index 322addd..161f160 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -60,8 +60,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
60 // The pair of Dictionaries are used to handle the switching of classified ads 60 // The pair of Dictionaries are used to handle the switching of classified ads
61 // by maintaining a cache of classified id to creator id mappings and an interest 61 // by maintaining a cache of classified id to creator id mappings and an interest
62 // count. The entries are removed when the interest count reaches 0. 62 // count. The entries are removed when the interest count reaches 0.
63 Dictionary<UUID,UUID> classifiedCache = new Dictionary<UUID, UUID>(); 63 Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>();
64 Dictionary<UUID,int> classifiedInterest = new Dictionary<UUID, int>(); 64 Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>();
65 65
66 public Scene Scene 66 public Scene Scene
67 { 67 {
@@ -102,7 +102,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
102 102
103 /// <summary> 103 /// <summary>
104 /// Gets or sets a value indicating whether this 104 /// Gets or sets a value indicating whether this
105 /// <see cref="BlueWall.SlipStream.ProfileModule.UserProfileModule"/> is enabled. 105 /// <see cref="OpenSim.Region.Coremodules.UserProfiles.UserProfileModule"/> is enabled.
106 /// </summary> 106 /// </summary>
107 /// <value> 107 /// <value>
108 /// <c>true</c> if enabled; otherwise, <c>false</c>. 108 /// <c>true</c> if enabled; otherwise, <c>false</c>.
@@ -331,16 +331,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
331 331
332 classifieds[cid] = name; 332 classifieds[cid] = name;
333 333
334 if(!classifiedCache.ContainsKey(cid)) 334 lock (m_classifiedCache)
335 { 335 {
336 lock(classifiedCache) 336 if (!m_classifiedCache.ContainsKey(cid))
337 classifiedCache.Add(cid,creatorId); 337 {
338 lock(classifiedInterest) 338 m_classifiedCache.Add(cid,creatorId);
339 classifiedInterest.Add(cid, 0); 339 m_classifiedInterest.Add(cid, 0);
340 } 340 }
341 341
342 lock(classifiedInterest) 342 m_classifiedInterest[cid]++;
343 classifiedInterest[cid] ++; 343 }
344 } 344 }
345 345
346 remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); 346 remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
@@ -352,19 +352,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
352 UserClassifiedAdd ad = new UserClassifiedAdd(); 352 UserClassifiedAdd ad = new UserClassifiedAdd();
353 ad.ClassifiedId = queryClassifiedID; 353 ad.ClassifiedId = queryClassifiedID;
354 354
355 if(classifiedCache.ContainsKey(queryClassifiedID)) 355 lock (m_classifiedCache)
356 { 356 {
357 target = classifiedCache[queryClassifiedID]; 357 if (m_classifiedCache.ContainsKey(queryClassifiedID))
358 {
359 target = m_classifiedCache[queryClassifiedID];
358 360
359 lock(classifiedInterest) 361 m_classifiedInterest[queryClassifiedID] --;
360 classifiedInterest[queryClassifiedID] --;
361 362
362 if(classifiedInterest[queryClassifiedID] == 0) 363 if (m_classifiedInterest[queryClassifiedID] == 0)
363 { 364 {
364 lock(classifiedInterest) 365 m_classifiedInterest.Remove(queryClassifiedID);
365 classifiedInterest.Remove(queryClassifiedID); 366 m_classifiedCache.Remove(queryClassifiedID);
366 lock(classifiedCache) 367 }
367 classifiedCache.Remove(queryClassifiedID);
368 } 368 }
369 } 369 }
370 370
@@ -1339,4 +1339,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
1339 } 1339 }
1340 #endregion Web Util 1340 #endregion Web Util
1341 } 1341 }
1342} 1342} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index 1e434b9..2fc8ee3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -1,11 +1,41 @@
1using System; 1/*
2using System.Collections.Generic; 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 */
3 27
28using System;
29using System.Collections.Generic;
30using System.Threading;
4using OpenSim.Framework; 31using OpenSim.Framework;
5using OpenMetaverse; 32using OpenMetaverse;
6 33
7namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 34namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
8{ 35{
36 /// <summary>
37 /// Cache root and system inventory folders to reduce number of potentially remote inventory calls and associated holdups.
38 /// </summary>
9 public class InventoryCache 39 public class InventoryCache
10 { 40 {
11 private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour 41 private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour
@@ -16,8 +46,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
16 46
17 public void Cache(UUID userID, InventoryFolderBase root) 47 public void Cache(UUID userID, InventoryFolderBase root)
18 { 48 {
19 lock (m_RootFolders) 49 m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
20 m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
21 } 50 }
22 51
23 public InventoryFolderBase GetRootFolder(UUID userID) 52 public InventoryFolderBase GetRootFolder(UUID userID)
@@ -31,14 +60,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
31 60
32 public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) 61 public void Cache(UUID userID, AssetType type, InventoryFolderBase folder)
33 { 62 {
34 lock (m_FolderTypes) 63 Dictionary<AssetType, InventoryFolderBase> ff = null;
64 if (!m_FolderTypes.TryGetValue(userID, out ff))
65 {
66 ff = new Dictionary<AssetType, InventoryFolderBase>();
67 m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
68 }
69
70 // We need to lock here since two threads could potentially retrieve the same dictionary
71 // and try to add a folder for that type simultaneously. Dictionary<>.Add() is not described as thread-safe in the SDK
72 // even if the folders are identical.
73 lock (ff)
35 { 74 {
36 Dictionary<AssetType, InventoryFolderBase> ff = null;
37 if (!m_FolderTypes.TryGetValue(userID, out ff))
38 {
39 ff = new Dictionary<AssetType, InventoryFolderBase>();
40 m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
41 }
42 if (!ff.ContainsKey(type)) 75 if (!ff.ContainsKey(type))
43 ff.Add(type, folder); 76 ff.Add(type, folder);
44 } 77 }
@@ -50,8 +83,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
50 if (m_FolderTypes.TryGetValue(userID, out ff)) 83 if (m_FolderTypes.TryGetValue(userID, out ff))
51 { 84 {
52 InventoryFolderBase f = null; 85 InventoryFolderBase f = null;
53 if (ff.TryGetValue(type, out f)) 86
54 return f; 87 lock (ff)
88 {
89 if (ff.TryGetValue(type, out f))
90 return f;
91 }
55 } 92 }
56 93
57 return null; 94 return null;
@@ -59,8 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
59 96
60 public void Cache(UUID userID, InventoryCollection inv) 97 public void Cache(UUID userID, InventoryCollection inv)
61 { 98 {
62 lock (m_Inventories) 99 m_Inventories.AddOrUpdate(userID, inv, 120);
63 m_Inventories.AddOrUpdate(userID, inv, 120);
64 } 100 }
65 101
66 public InventoryCollection GetUserInventory(UUID userID) 102 public InventoryCollection GetUserInventory(UUID userID)