aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Friends
diff options
context:
space:
mode:
authorDiva Canto2010-06-10 21:59:12 -0700
committerDiva Canto2010-06-10 21:59:12 -0700
commit2e1269e4cac8542dbf74854ec4d3196f4e0cd372 (patch)
treea22b8080ee973cf3f8a0a41e12ff440e4d6b8ed0 /OpenSim/Region/CoreModules/Avatar/Friends
parentAdded more debug messages to try to pinpoint where login is failing for nebadon. (diff)
downloadopensim-SC_OLD-2e1269e4cac8542dbf74854ec4d3196f4e0cd372.zip
opensim-SC_OLD-2e1269e4cac8542dbf74854ec4d3196f4e0cd372.tar.gz
opensim-SC_OLD-2e1269e4cac8542dbf74854ec4d3196f4e0cd372.tar.bz2
opensim-SC_OLD-2e1269e4cac8542dbf74854ec4d3196f4e0cd372.tar.xz
Bug fix on friends notifications. OnClientClose and OnLogout ordering are unpredictable; when OnClientClosed happened first, it was removing the friends list, which would prevent OnLogout notifications to go out.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs41
1 files changed, 33 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 3590f27..4f0487b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -245,11 +245,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
245 245
246 private void OnClientClosed(UUID agentID, Scene scene) 246 private void OnClientClosed(UUID agentID, Scene scene)
247 { 247 {
248 ScenePresence sp = scene.GetScenePresence(agentID);
248 lock (m_Friends) 249 lock (m_Friends)
249 if (m_Friends.ContainsKey(agentID)) 250 if (m_Friends.ContainsKey(agentID))
250 { 251 {
251 if (m_Friends[agentID].Refcount == 1) 252 if (m_Friends[agentID].Refcount == 1)
252 m_Friends.Remove(agentID); 253 {
254 if (sp != null && sp.IsChildAgent)
255 // we do this only for child agents
256 // Root agents' closing = logout; that's
257 // processed with OnLogout
258 {
259 m_Friends.Remove(agentID);
260 }
261 }
253 else 262 else
254 m_Friends[agentID].Refcount--; 263 m_Friends[agentID].Refcount--;
255 } 264 }
@@ -267,11 +276,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
267 276
268 if (m_Friends.ContainsKey(agentID)) 277 if (m_Friends.ContainsKey(agentID))
269 { 278 {
270 if (m_Friends[agentID].RegionID == UUID.Zero) 279 // This is probably an overkill, but just
271 { 280 // to make sure we have the latest and greatest
272 m_Friends[agentID].Friends = 281 // friends list -- always pull OnMakeRoot
282 m_Friends[agentID].Friends =
273 m_FriendsService.GetFriends(agentID); 283 m_FriendsService.GetFriends(agentID);
274 } 284
275 m_Friends[agentID].RegionID = 285 m_Friends[agentID].RegionID =
276 sp.ControllingClient.Scene.RegionInfo.RegionID; 286 sp.ControllingClient.Scene.RegionInfo.RegionID;
277 } 287 }
@@ -437,8 +447,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
437 /// <param name="online"></param> 447 /// <param name="online"></param>
438 private void StatusChange(UUID agentID, bool online) 448 private void StatusChange(UUID agentID, bool online)
439 { 449 {
450 //m_log.DebugFormat("[FRIENDS]: StatusChange {0}", online);
440 if (m_Friends.ContainsKey(agentID)) 451 if (m_Friends.ContainsKey(agentID))
441 { 452 {
453 //m_log.DebugFormat("[FRIENDS]: # of friends: {0}", m_Friends[agentID].Friends.Length);
442 List<FriendInfo> friendList = new List<FriendInfo>(); 454 List<FriendInfo> friendList = new List<FriendInfo>();
443 foreach (FriendInfo fi in m_Friends[agentID].Friends) 455 foreach (FriendInfo fi in m_Friends[agentID].Friends)
444 { 456 {
@@ -447,10 +459,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
447 } 459 }
448 foreach (FriendInfo fi in friendList) 460 foreach (FriendInfo fi in friendList)
449 { 461 {
462 //m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID);
450 // Notify about this user status 463 // Notify about this user status
451 StatusNotify(fi, agentID, online); 464 StatusNotify(fi, agentID, online);
452 } 465 }
453 } 466 }
467 else
468 m_log.WarnFormat("[FRIENDS]: {0} not found in cache", agentID);
454 } 469 }
455 470
456 private void StatusNotify(FriendInfo friend, UUID userID, bool online) 471 private void StatusNotify(FriendInfo friend, UUID userID, bool online)
@@ -462,21 +477,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
462 // Try local 477 // Try local
463 if (LocalStatusNotification(userID, friendID, online)) 478 if (LocalStatusNotification(userID, friendID, online))
464 return; 479 return;
465 480
466 // The friend is not here [as root]. Let's forward. 481 // The friend is not here [as root]. Let's forward.
467 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); 482 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
468 if (friendSessions != null && friendSessions.Length > 0) 483 if (friendSessions != null && friendSessions.Length > 0)
469 { 484 {
470 PresenceInfo friendSession = friendSessions[0]; 485 PresenceInfo friendSession = null;
486 foreach (PresenceInfo pinfo in friendSessions)
487 if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad
488 {
489 friendSession = pinfo;
490 break;
491 }
492
471 if (friendSession != null) 493 if (friendSession != null)
472 { 494 {
473 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 495 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
496 //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName);
474 m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); 497 m_FriendsSimConnector.StatusNotify(region, userID, friendID, online);
475 } 498 }
476 } 499 }
477 500
478 // Friend is not online. Ignore. 501 // Friend is not online. Ignore.
479 } 502 }
503 else
504 m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend);
480 } 505 }
481 506
482 private void OnInstantMessage(IClientAPI client, GridInstantMessage im) 507 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
@@ -763,7 +788,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
763 IClientAPI friendClient = LocateClientObject(friendID); 788 IClientAPI friendClient = LocateClientObject(friendID);
764 if (friendClient != null) 789 if (friendClient != null)
765 { 790 {
766 //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online); 791 //m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
767 // the friend in this sim as root agent 792 // the friend in this sim as root agent
768 if (online) 793 if (online)
769 friendClient.SendAgentOnline(new UUID[] { userID }); 794 friendClient.SendAgentOnline(new UUID[] { userID });