aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorOren Hurvitz2014-04-21 14:57:31 +0300
committerOren Hurvitz2014-04-21 16:56:49 +0100
commit4cac87d9f421d937422c0f9afbe1ba66c66bad17 (patch)
tree896ca286529e3b72e9c97f1ee2af3a2e6381a961 /OpenSim
parentBetter error handling when retrieving offline IMs (diff)
downloadopensim-SC_OLD-4cac87d9f421d937422c0f9afbe1ba66c66bad17.zip
opensim-SC_OLD-4cac87d9f421d937422c0f9afbe1ba66c66bad17.tar.gz
opensim-SC_OLD-4cac87d9f421d937422c0f9afbe1ba66c66bad17.tar.bz2
opensim-SC_OLD-4cac87d9f421d937422c0f9afbe1ba66c66bad17.tar.xz
Fixed: when a user logged-in, sometimes he didn't get notified of the Online status of friends, so they continued to appear Offline.
This happened because these notifications (the UDP packets) can only be sent to Root Agents. But the notifications were done in OnClientLogin(), at which point the client is still a Child Agent. Since a FireAndForget is used, it became a race condition as to whether the packets would be sent before or after the client became a Root Agent. To fix this, we now only send the notifications once the client becomes a Root Agent for the first time.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs24
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs2
2 files changed, 24 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index b693f2d..31bcded 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -94,6 +94,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
94 protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>(); 94 protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>();
95 95
96 /// <summary> 96 /// <summary>
97 /// Maintain a record of clients that need to notify about their online status. This only
98 /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism.
99 /// </summary>
100 protected HashSet<UUID> m_NeedsToNotifyStatus = new HashSet<UUID>();
101
102 /// <summary>
97 /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only 103 /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only
98 /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. 104 /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism.
99 /// </summary> 105 /// </summary>
@@ -324,6 +330,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
324 private void OnMakeRootAgent(ScenePresence sp) 330 private void OnMakeRootAgent(ScenePresence sp)
325 { 331 {
326 RecacheFriends(sp.ControllingClient); 332 RecacheFriends(sp.ControllingClient);
333
334 lock (m_NeedsToNotifyStatus)
335 {
336 if (m_NeedsToNotifyStatus.Remove(sp.UUID))
337 {
338 // Inform the friends that this user is online. This can only be done once the client is a Root Agent.
339 StatusChange(sp.UUID, true);
340 }
341 }
327 } 342 }
328 343
329 private void OnClientLogin(IClientAPI client) 344 private void OnClientLogin(IClientAPI client)
@@ -331,8 +346,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
331 UUID agentID = client.AgentId; 346 UUID agentID = client.AgentId;
332 347
333 //m_log.DebugFormat("[XXX]: OnClientLogin!"); 348 //m_log.DebugFormat("[XXX]: OnClientLogin!");
334 // Inform the friends that this user is online 349
335 StatusChange(agentID, true); 350 // Register that we need to send this user's status to friends. This can only be done
351 // once the client becomes a Root Agent, because as part of sending out the presence
352 // we also get back the presence of the HG friends, and we need to send that to the
353 // client, but that can only be done when the client is a Root Agent.
354 lock (m_NeedsToNotifyStatus)
355 m_NeedsToNotifyStatus.Add(agentID);
336 356
337 // Register that we need to send the list of online friends to this user 357 // Register that we need to send the list of online friends to this user
338 lock (m_NeedsListOfOnlineFriends) 358 lock (m_NeedsListOfOnlineFriends)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index d00945e..be12935 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -239,6 +239,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
239 fList.Add(s.Substring(0, 36)); 239 fList.Add(s.Substring(0, 36));
240 } 240 }
241 241
242 // FIXME: also query the presence status of friends in other grids (like in HGStatusNotifier.Notify())
243
242 PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray()); 244 PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray());
243 foreach (PresenceInfo pi in presence) 245 foreach (PresenceInfo pi in presence)
244 { 246 {