UserProfileModule threading issues

melanie
UbitUmarov 2016-12-23 02:17:42 +00:00
parent 0ae2b5ac81
commit 2e7e4427d0
1 changed files with 77 additions and 63 deletions

View File

@ -438,12 +438,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
} }
} }
if(uce == null) lock(m_profilesCache)
uce = new UserProfileCacheEntry(); {
uce.classifiedsLists = classifieds; if(!m_profilesCache.TryGetValue(targetID, out uce) || uce == null)
uce = new UserProfileCacheEntry();
uce.classifiedsLists = classifieds;
lock(m_profilesCache)
m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE); m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE);
}
remoteClient.SendAvatarClassifiedReply(targetID, classifieds); remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
} }
@ -512,14 +514,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if(foreign) if(foreign)
cacheForeignImage(target, ad.SnapshotId); cacheForeignImage(target, ad.SnapshotId);
if(uce == null)
uce = new UserProfileCacheEntry();
if(uce.classifieds == null)
uce.classifieds = new Dictionary<UUID, UserClassifiedAdd>();
uce.classifieds[ad.ClassifiedId] = ad;
lock(m_profilesCache) lock(m_profilesCache)
m_profilesCache.AddOrUpdate(ad.ClassifiedId, uce, PROFILECACHEEXPIRE); {
if(!m_profilesCache.TryGetValue(target, out uce) || uce == null)
uce = new UserProfileCacheEntry();
if(uce.classifieds == null)
uce.classifieds = new Dictionary<UUID, UserClassifiedAdd>();
uce.classifieds[ad.ClassifiedId] = ad;
m_profilesCache.AddOrUpdate(target, uce, PROFILECACHEEXPIRE);
}
Vector3 globalPos = new Vector3(); Vector3 globalPos = new Vector3();
Vector3.TryParse(ad.GlobalPos, out globalPos); Vector3.TryParse(ad.GlobalPos, out globalPos);
@ -659,7 +663,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
// just flush cache for now // just flush cache for now
lock(m_profilesCache) lock(m_profilesCache)
{ {
if(uce != null) if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{ {
uce.classifieds = null; uce.classifieds = null;
uce.classifiedsLists = null; uce.classifiedsLists = null;
@ -679,16 +683,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// </param> /// </param>
public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient) public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
{ {
// just flush cache for now
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.classifieds = null;
uce.classifiedsLists = null;
}
}
string serverURI = string.Empty; string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
@ -700,6 +694,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true); remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true);
return; return;
} }
UUID classifiedId; UUID classifiedId;
if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId)) if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId))
return; return;
@ -714,6 +709,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return; return;
} }
// flush cache
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.classifieds = null;
uce.classifiedsLists = null;
}
}
parameters = (OSDMap)Params; parameters = (OSDMap)Params;
} }
#endregion Classified #endregion Classified
@ -797,12 +803,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
picks[cid] = name; picks[cid] = name;
} }
if (uce == null)
uce = new UserProfileCacheEntry();
uce.picksList = picks;
lock(m_profilesCache) lock(m_profilesCache)
{
if(!m_profilesCache.TryGetValue(targetId, out uce) || uce == null)
uce = new UserProfileCacheEntry();
uce.picksList = picks;
m_profilesCache.AddOrUpdate(targetId, uce, PROFILECACHEEXPIRE); m_profilesCache.AddOrUpdate(targetId, uce, PROFILECACHEEXPIRE);
}
remoteClient.SendAvatarPicksReply(targetId, picks); remoteClient.SendAvatarPicksReply(targetId, picks);
} }
@ -903,14 +911,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString()); m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString());
pick.GlobalPos = globalPos.ToString(); pick.GlobalPos = globalPos.ToString();
if (uce == null)
uce = new UserProfileCacheEntry();
if(uce.picks == null)
uce.picks = new Dictionary<UUID, UserProfilePick>();
uce.picks[pick.PickId] = pick;
lock(m_profilesCache) lock(m_profilesCache)
{
if(!m_profilesCache.TryGetValue(targetID, out uce) || uce == null)
uce = new UserProfileCacheEntry();
if(uce.picks == null)
uce.picks = new Dictionary<UUID, UserProfilePick>();
uce.picks[pick.PickId] = pick;
m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE); m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE);
}
// Pull the rabbit out of the hat // Pull the rabbit out of the hat
remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name, remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name,
@ -950,7 +960,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// </param> /// </param>
public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled) public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
{ {
//TODO: See how this works with NPC, May need to test
m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString()); m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
UserProfilePick pick = new UserProfilePick(); UserProfilePick pick = new UserProfilePick();
@ -1067,11 +1076,11 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{ {
if(uce.picks != null && uce.picks.ContainsKey(queryPickID)) if(uce.picks != null && uce.picks.ContainsKey(queryPickID))
uce.picks.Remove(queryPickID); uce.picks.Remove(queryPickID);
if(uce.picksList != null && uce.picksList.ContainsKey(queryPickID)) if(uce.picksList != null && uce.picksList.ContainsKey(queryPickID))
uce.picksList.Remove(queryPickID); uce.picksList.Remove(queryPickID);
m_profilesCache.AddOrUpdate(remoteClient.AgentId, uce, PROFILECACHEEXPIRE); m_profilesCache.AddOrUpdate(remoteClient.AgentId, uce, PROFILECACHEEXPIRE);
} }
} }
if(uce != null && uce.picksList != null) if(uce != null && uce.picksList != null)
@ -1259,15 +1268,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// </param> /// </param>
public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
{ {
// flush cache for now
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.props = null;
}
}
UserProfileProperties prop = new UserProfileProperties(); UserProfileProperties prop = new UserProfileProperties();
@ -1290,6 +1290,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
"Error updating interests", false); "Error updating interests", false);
return; return;
} }
// flush cache
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.props = null;
}
}
} }
public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
@ -1399,15 +1410,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if(!m_allowUserProfileWebURLs) if(!m_allowUserProfileWebURLs)
props.WebUrl =""; props.WebUrl ="";
if(uce == null)
uce = new UserProfileCacheEntry();
uce.props = props;
uce.born = born;
uce.membershipType = membershipType;
uce.flags = flags;
lock(m_profilesCache) lock(m_profilesCache)
{
if(!m_profilesCache.TryGetValue(props.UserId, out uce) || uce == null)
uce = new UserProfileCacheEntry();
uce.props = props;
uce.born = born;
uce.membershipType = membershipType;
uce.flags = flags;
m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE); m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE);
}
remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags, remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags,
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
@ -1429,15 +1442,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
if (remoteClient.AgentId == newProfile.ID) if (remoteClient.AgentId == newProfile.ID)
{ {
// flush cache for now
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.props = null;
}
}
UserProfileProperties prop = new UserProfileProperties(); UserProfileProperties prop = new UserProfileProperties();
@ -1463,6 +1467,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return; return;
} }
// flush cache
UserProfileCacheEntry uce = null;
lock(m_profilesCache)
{
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
{
uce.props = null;
}
}
RequestAvatarProperties(remoteClient, newProfile.ID); RequestAvatarProperties(remoteClient, newProfile.ID);
} }
} }