aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
diff options
context:
space:
mode:
authorMW2008-02-13 16:29:34 +0000
committerMW2008-02-13 16:29:34 +0000
commitd91c03e23b13def6019eae98cbd72b0a8e9e192a (patch)
tree3bffccad5113b38a67966d376fe84aa1b4dc4d30 /OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
parent* Fix for mantis 522. However, I would be a little surprised if this code di... (diff)
downloadopensim-SC_OLD-d91c03e23b13def6019eae98cbd72b0a8e9e192a.zip
opensim-SC_OLD-d91c03e23b13def6019eae98cbd72b0a8e9e192a.tar.gz
opensim-SC_OLD-d91c03e23b13def6019eae98cbd72b0a8e9e192a.tar.bz2
opensim-SC_OLD-d91c03e23b13def6019eae98cbd72b0a8e9e192a.tar.xz
Added some locks on the cache Dictionary in AvatarFactoryModule.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs35
1 files changed, 25 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
index 9604bb3..b8b6be8 100644
--- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
@@ -53,31 +53,44 @@ namespace OpenSim.Region.Environment.Modules
53 53
54 public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) 54 public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
55 { 55 {
56 if (m_avatarsAppearance.ContainsKey(avatarId)) 56 //check cache
57 lock (m_avatarsAppearance)
57 { 58 {
58 appearance = m_avatarsAppearance[avatarId]; 59 if (m_avatarsAppearance.ContainsKey(avatarId))
59 return true; 60 {
61 appearance = m_avatarsAppearance[avatarId];
62 return true;
63 }
60 } 64 }
61 65
66 //check db
62 if (m_enablePersist) 67 if (m_enablePersist)
63 { 68 {
64 if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance)) 69 if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance))
65 { 70 {
66 appearance.VisualParams = GetDefaultVisualParams(); 71 appearance.VisualParams = GetDefaultVisualParams();
67 appearance.TextureEntry = AvatarAppearance.GetDefaultTextureEntry(); 72 appearance.TextureEntry = AvatarAppearance.GetDefaultTextureEntry();
68 m_avatarsAppearance.Add(avatarId, appearance); 73 lock (m_avatarsAppearance)
74 {
75 m_avatarsAppearance.Add(avatarId, appearance);
76 }
69 return true; 77 return true;
70 } 78 }
71 } 79 }
72 80
73 81 //not found a appearance for the user, so create a new one
74 //not found a appearance for user, so create a new one
75 AvatarWearable[] wearables; 82 AvatarWearable[] wearables;
76 byte[] visualParams; 83 byte[] visualParams;
77 GetDefaultAvatarAppearance(out wearables, out visualParams); 84 GetDefaultAvatarAppearance(out wearables, out visualParams);
78 appearance = new AvatarAppearance(avatarId, wearables, visualParams); 85 appearance = new AvatarAppearance(avatarId, wearables, visualParams);
79 86
80 m_avatarsAppearance.Add(avatarId, appearance); 87 //add appearance to dictionary cache
88 lock (m_avatarsAppearance)
89 {
90 m_avatarsAppearance.Add(avatarId, appearance);
91 }
92
93 //update database
81 if (m_enablePersist) 94 if (m_enablePersist)
82 { 95 {
83 m_appearanceMapper.Add(avatarId.UUID, appearance); 96 m_appearanceMapper.Add(avatarId.UUID, appearance);
@@ -162,11 +175,13 @@ namespace OpenSim.Region.Environment.Modules
162 if (baseItem != null) 175 if (baseItem != null)
163 { 176 {
164 assetId = baseItem.assetID; 177 assetId = baseItem.assetID;
165 //temporary dictionary storage. This should be storing to a database 178
166
167 if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) 179 if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
168 { 180 {
169 AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; 181 lock (m_avatarsAppearance)
182 {
183 AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId];
184 }
170 avatAppearance.Wearables[wear.Type].AssetID = assetId; 185 avatAppearance.Wearables[wear.Type].AssetID = assetId;
171 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; 186 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
172 187