Permalink
Browse files

LIBOMV-611: FriendsManager Exception An entry with the same key alrea…

…dy exists, patch by Douglas R. Miles

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2934 52acb1d6-8a22-11de-b505-999d5b087335
  • Loading branch information...
1 parent 29cb7d1 commit 5b484e0070f2ac9d753126c78e3590aa1b434334 @lkalif lkalif committed Jun 29, 2009
Showing with 29 additions and 18 deletions.
  1. +29 −18 OpenMetaverse/FriendsManager.cs
@@ -552,13 +552,16 @@ private void Avatars_OnAvatarNames(Dictionary<UUID, string> names)
foreach (KeyValuePair<UUID, string> kvp in names)
{
FriendInfo friend;
- if (FriendList.TryGetValue(kvp.Key, out friend))
+ lock (FriendList.Dictionary)
{
- if (friend.Name == null)
- newNames.Add(kvp.Key, names[kvp.Key]);
+ if (FriendList.TryGetValue(kvp.Key, out friend))
+ {
+ if (friend.Name == null)
+ newNames.Add(kvp.Key, names[kvp.Key]);
- friend.Name = names[kvp.Key];
- FriendList[kvp.Key] = friend;
+ friend.Name = names[kvp.Key];
+ FriendList[kvp.Key] = friend;
+ }
}
}
@@ -586,16 +589,18 @@ private void OnlineNotificationHandler(Packet packet, Simulator simulator)
foreach (OnlineNotificationPacket.AgentBlockBlock block in notification.AgentBlock)
{
FriendInfo friend;
-
- if (!FriendList.ContainsKey(block.AgentID))
- {
- friend = new FriendInfo(block.AgentID, FriendRights.CanSeeOnline,
- FriendRights.CanSeeOnline);
- FriendList.Add(block.AgentID, friend);
- }
- else
+ lock (FriendList.Dictionary)
{
- friend = FriendList[block.AgentID];
+ if (!FriendList.ContainsKey(block.AgentID))
+ {
+ friend = new FriendInfo(block.AgentID, FriendRights.CanSeeOnline,
+ FriendRights.CanSeeOnline);
+ FriendList.Add(block.AgentID, friend);
+ }
+ else
+ {
+ friend = FriendList[block.AgentID];
+ }
}
bool doNotify = !friend.IsOnline;
@@ -735,7 +740,7 @@ private void MainAvatar_InstantMessage(InstantMessage im, Simulator simulator)
FriendInfo friend = new FriendInfo(im.FromAgentID, FriendRights.CanSeeOnline,
FriendRights.CanSeeOnline);
friend.Name = im.FromAgentName;
- FriendList[friend.UUID] = friend;
+ lock (FriendList.Dictionary) FriendList[friend.UUID] = friend;
if (OnFriendshipResponse != null)
{
@@ -771,14 +776,20 @@ private void MainAvatar_InstantMessage(InstantMessage im, Simulator simulator)
{
foreach (BuddyListEntry buddy in replyData.BuddyList)
{
- FriendList.Add(UUID.Parse(buddy.buddy_id),
- new FriendInfo(UUID.Parse(buddy.buddy_id),
+ UUID bubid = UUID.Parse(buddy.buddy_id);
+ lock (FriendList.Dictionary)
+ {
+ if (!FriendList.ContainsKey(bubid))
+ {
+ FriendList.Add(bubid,
+ new FriendInfo(UUID.Parse(buddy.buddy_id),
(FriendRights)buddy.buddy_rights_given,
(FriendRights)buddy.buddy_rights_has));
+ }
+ }
}
}
}
}
-
}
}

0 comments on commit 5b484e0

Please sign in to comment.