Added some locks on the cache Dictionary in AvatarFactoryModule.
parent
5e9ae68df4
commit
d91c03e23b
|
@ -52,32 +52,45 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
private AppearanceTableMapper m_appearanceMapper;
|
private AppearanceTableMapper m_appearanceMapper;
|
||||||
|
|
||||||
public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
|
public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
|
||||||
|
{
|
||||||
|
//check cache
|
||||||
|
lock (m_avatarsAppearance)
|
||||||
{
|
{
|
||||||
if (m_avatarsAppearance.ContainsKey(avatarId))
|
if (m_avatarsAppearance.ContainsKey(avatarId))
|
||||||
{
|
{
|
||||||
appearance = m_avatarsAppearance[avatarId];
|
appearance = m_avatarsAppearance[avatarId];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check db
|
||||||
if (m_enablePersist)
|
if (m_enablePersist)
|
||||||
{
|
{
|
||||||
if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance))
|
if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance))
|
||||||
{
|
{
|
||||||
appearance.VisualParams = GetDefaultVisualParams();
|
appearance.VisualParams = GetDefaultVisualParams();
|
||||||
appearance.TextureEntry = AvatarAppearance.GetDefaultTextureEntry();
|
appearance.TextureEntry = AvatarAppearance.GetDefaultTextureEntry();
|
||||||
|
lock (m_avatarsAppearance)
|
||||||
|
{
|
||||||
m_avatarsAppearance.Add(avatarId, appearance);
|
m_avatarsAppearance.Add(avatarId, appearance);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not found a appearance for the user, so create a new one
|
||||||
//not found a appearance for user, so create a new one
|
|
||||||
AvatarWearable[] wearables;
|
AvatarWearable[] wearables;
|
||||||
byte[] visualParams;
|
byte[] visualParams;
|
||||||
GetDefaultAvatarAppearance(out wearables, out visualParams);
|
GetDefaultAvatarAppearance(out wearables, out visualParams);
|
||||||
appearance = new AvatarAppearance(avatarId, wearables, visualParams);
|
appearance = new AvatarAppearance(avatarId, wearables, visualParams);
|
||||||
|
|
||||||
|
//add appearance to dictionary cache
|
||||||
|
lock (m_avatarsAppearance)
|
||||||
|
{
|
||||||
m_avatarsAppearance.Add(avatarId, appearance);
|
m_avatarsAppearance.Add(avatarId, appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
//update database
|
||||||
if (m_enablePersist)
|
if (m_enablePersist)
|
||||||
{
|
{
|
||||||
m_appearanceMapper.Add(avatarId.UUID, appearance);
|
m_appearanceMapper.Add(avatarId.UUID, appearance);
|
||||||
|
@ -162,11 +175,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
if (baseItem != null)
|
if (baseItem != null)
|
||||||
{
|
{
|
||||||
assetId = baseItem.assetID;
|
assetId = baseItem.assetID;
|
||||||
//temporary dictionary storage. This should be storing to a database
|
|
||||||
|
|
||||||
if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
|
if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
|
||||||
|
{
|
||||||
|
lock (m_avatarsAppearance)
|
||||||
{
|
{
|
||||||
AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId];
|
AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId];
|
||||||
|
}
|
||||||
avatAppearance.Wearables[wear.Type].AssetID = assetId;
|
avatAppearance.Wearables[wear.Type].AssetID = assetId;
|
||||||
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
|
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue