aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-29 01:08:47 +0100
committerJustin Clark-Casey (justincc)2012-03-29 01:08:47 +0100
commit93ac47f0d3968650bd7758ad0981e8e5d49b8138 (patch)
treede296d7d41d9094365b6d17b6bc9cb98e6d7396c /OpenSim
parentRevert "Add comment about setting client.SceneAgent in AddNewClient()" (diff)
downloadopensim-SC_OLD-93ac47f0d3968650bd7758ad0981e8e5d49b8138.zip
opensim-SC_OLD-93ac47f0d3968650bd7758ad0981e8e5d49b8138.tar.gz
opensim-SC_OLD-93ac47f0d3968650bd7758ad0981e8e5d49b8138.tar.bz2
opensim-SC_OLD-93ac47f0d3968650bd7758ad0981e8e5d49b8138.tar.xz
Revert "Simplify friends caching by only doing this for root agents - no functions require caching for child agents."
We need to cache child agents so that friends object edit/delete permissions will work across boarders on regions hosted by different simulators. This reverts commit d9f7b8549b3cb9699eb8bd54242d31aac0f8241a.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs62
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
9 files changed, 55 insertions, 31 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 1e36b06..3f560d0 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -710,7 +710,7 @@ namespace OpenSim.Framework
710 /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it 710 /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it
711 /// is connected). 711 /// is connected).
712 /// </summary> 712 /// </summary>
713 ISceneAgent SceneAgent { get; set; } 713 ISceneAgent SceneAgent { get; }
714 714
715 UUID SessionId { get; } 715 UUID SessionId { get; }
716 716
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 9899669..cd81df5 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
384 set { m_startpos = value; } 384 set { m_startpos = value; }
385 } 385 }
386 public UUID AgentId { get { return m_agentId; } } 386 public UUID AgentId { get { return m_agentId; } }
387 public ISceneAgent SceneAgent { get; set; } 387 public ISceneAgent SceneAgent { get; private set; }
388 public UUID ActiveGroupId { get { return m_activeGroupID; } } 388 public UUID ActiveGroupId { get { return m_activeGroupID; } }
389 public string ActiveGroupName { get { return m_activeGroupName; } } 389 public string ActiveGroupName { get { return m_activeGroupName; } }
390 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } 390 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
@@ -695,7 +695,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
695 695
696 public virtual void Start() 696 public virtual void Start()
697 { 697 {
698 m_scene.AddNewClient(this, PresenceType.User); 698 SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
699 699
700 RefreshGroupMembership(); 700 RefreshGroupMembership();
701 } 701 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4cc0e19..aadd3bc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
57 { 57 {
58 public UUID PrincipalID; 58 public UUID PrincipalID;
59 public FriendInfo[] Friends; 59 public FriendInfo[] Friends;
60 public int Refcount;
60 61
61 public bool IsFriend(string friend) 62 public bool IsFriend(string friend)
62 { 63 {
@@ -254,9 +255,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
254 255
255 private void OnNewClient(IClientAPI client) 256 private void OnNewClient(IClientAPI client)
256 { 257 {
257 if (client.SceneAgent.IsChildAgent)
258 return;
259
260 client.OnInstantMessage += OnInstantMessage; 258 client.OnInstantMessage += OnInstantMessage;
261 client.OnApproveFriendRequest += OnApproveFriendRequest; 259 client.OnApproveFriendRequest += OnApproveFriendRequest;
262 client.OnDenyFriendRequest += OnDenyFriendRequest; 260 client.OnDenyFriendRequest += OnDenyFriendRequest;
@@ -283,14 +281,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
283 UUID agentID = client.AgentId; 281 UUID agentID = client.AgentId;
284 lock (m_Friends) 282 lock (m_Friends)
285 { 283 {
286 UserFriendData friendsData = new UserFriendData(); 284 UserFriendData friendsData;
287 friendsData.PrincipalID = agentID; 285 if (m_Friends.TryGetValue(agentID, out friendsData))
288 friendsData.Friends = GetFriendsFromService(client); 286 {
287 friendsData.Refcount++;
288 return false;
289 }
290 else
291 {
292 friendsData = new UserFriendData();
293 friendsData.PrincipalID = agentID;
294 friendsData.Friends = GetFriendsFromService(client);
295 friendsData.Refcount = 1;
289 296
290 m_Friends[agentID] = friendsData; 297 m_Friends[agentID] = friendsData;
298 return true;
299 }
291 } 300 }
292
293 return true;
294 } 301 }
295 302
296 private void OnClientClosed(UUID agentID, Scene scene) 303 private void OnClientClosed(UUID agentID, Scene scene)
@@ -300,17 +307,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
300 { 307 {
301 // do this for root agents closing out 308 // do this for root agents closing out
302 StatusChange(agentID, false); 309 StatusChange(agentID, false);
310 }
303 311
304 lock (m_Friends) 312 lock (m_Friends)
305 m_Friends.Remove(agentID); 313 {
314 UserFriendData friendsData;
315 if (m_Friends.TryGetValue(agentID, out friendsData))
316 {
317 friendsData.Refcount--;
318 if (friendsData.Refcount <= 0)
319 m_Friends.Remove(agentID);
320 }
306 } 321 }
307 } 322 }
308 323
309 private void OnMakeRootAgent(ScenePresence sp) 324 private void OnMakeRootAgent(ScenePresence sp)
310 { 325 {
311 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event 326 RecacheFriends(sp.ControllingClient);
312 // is on the critical path for transferring an avatar from one region to another.
313 CacheFriends(sp.ControllingClient);
314 } 327 }
315 328
316 private void OnClientLogin(IClientAPI client) 329 private void OnClientLogin(IClientAPI client)
@@ -616,7 +629,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
616 } 629 }
617 630
618 // Update the local cache. 631 // Update the local cache.
619 CacheFriends(client); 632 RecacheFriends(client);
620 633
621 // 634 //
622 // Notify the friend 635 // Notify the friend
@@ -678,7 +691,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
678 client.SendAlertMessage("Unable to terminate friendship on this sim."); 691 client.SendAlertMessage("Unable to terminate friendship on this sim.");
679 692
680 // Update local cache 693 // Update local cache
681 CacheFriends(client); 694 RecacheFriends(client);
682 695
683 client.SendTerminateFriend(exfriendID); 696 client.SendTerminateFriend(exfriendID);
684 697
@@ -799,7 +812,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
799 812
800 813
801 // Update the local cache 814 // Update the local cache
802 CacheFriends(friendClient); 815 RecacheFriends(friendClient);
803 816
804 // we're done 817 // we're done
805 return true; 818 return true;
@@ -832,7 +845,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
832 // the friend in this sim as root agent 845 // the friend in this sim as root agent
833 friendClient.SendTerminateFriend(exfriendID); 846 friendClient.SendTerminateFriend(exfriendID);
834 // update local cache 847 // update local cache
835 CacheFriends(friendClient); 848 RecacheFriends(friendClient);
836 // we're done 849 // we're done
837 return true; 850 return true;
838 } 851 }
@@ -933,6 +946,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
933 return FriendsService.GetFriends(client.AgentId); 946 return FriendsService.GetFriends(client.AgentId);
934 } 947 }
935 948
949 protected void RecacheFriends(IClientAPI client)
950 {
951 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
952 // is on the critical path for transferring an avatar from one region to another.
953 UUID agentID = client.AgentId;
954 lock (m_Friends)
955 {
956 UserFriendData friendsData;
957 if (m_Friends.TryGetValue(agentID, out friendsData))
958 friendsData.Friends = GetFriendsFromService(client);
959 }
960 }
961
936 /// <summary> 962 /// <summary>
937 /// Are friends cached on this simulator for a particular user? 963 /// Are friends cached on this simulator for a particular user?
938 /// </summary> 964 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 7bc3018..e50a84a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
121 { 121 {
122 UUID agentID = client.AgentId; 122 UUID agentID = client.AgentId;
123 // we do this only for the root agent 123 // we do this only for the root agent
124 if (!client.SceneAgent.IsChildAgent) 124 if (m_Friends[agentID].Refcount == 1)
125 { 125 {
126 // We need to preload the user management cache with the names 126 // We need to preload the user management cache with the names
127 // of foreign friends, just like we do with SOPs' creators 127 // of foreign friends, just like we do with SOPs' creators
@@ -426,14 +426,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); 426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode);
427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); 427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
429 CacheFriends(agentClient); 429 RecacheFriends(agentClient);
430 } 430 }
431 if (friendClient != null) 431 if (friendClient != null)
432 { 432 {
433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); 433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); 434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);
435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
436 CacheFriends(friendClient); 436 RecacheFriends(friendClient);
437 } 437 }
438 438
439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", 439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}",
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index fe3438e..7993abe 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -71,7 +71,6 @@ namespace OpenSim.Region.Framework.Scenes
71 /// Triggered when a new client is added to the scene. 71 /// Triggered when a new client is added to the scene.
72 /// </summary> 72 /// </summary>
73 /// <remarks> 73 /// <remarks>
74 /// This is triggered for both child and root agent client connections.
75 /// Triggered before OnClientLogin. 74 /// Triggered before OnClientLogin.
76 /// </remarks> 75 /// </remarks>
77 public event OnNewClientDelegate OnNewClient; 76 public event OnNewClientDelegate OnNewClient;
@@ -192,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes
192 public delegate void ClientClosed(UUID clientID, Scene scene); 191 public delegate void ClientClosed(UUID clientID, Scene scene);
193 192
194 /// <summary> 193 /// <summary>
195 /// Fired when a client is removed from a scene whether it's a child or a root agent. 194 /// Fired when a client is removed from a scene.
196 /// </summary> 195 /// </summary>
197 /// <remarks> 196 /// <remarks>
198 /// At the point of firing, the scene still contains the client's scene presence. 197 /// At the point of firing, the scene still contains the client's scene presence.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 60fe48f..c887b4e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2670,7 +2670,6 @@ namespace OpenSim.Region.Framework.Scenes
2670 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); 2670 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
2671 } 2671 }
2672 2672
2673 client.SceneAgent = sp;
2674 m_LastLogin = Util.EnvironmentTickCount(); 2673 m_LastLogin = Util.EnvironmentTickCount();
2675 2674
2676 // Cache the user's name 2675 // Cache the user's name
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 43548e6..5cf478a 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
55 55
56 private UUID m_agentID = UUID.Random(); 56 private UUID m_agentID = UUID.Random();
57 57
58 public ISceneAgent SceneAgent { get; set; } 58 public ISceneAgent SceneAgent { get; private set; }
59 59
60 private string m_username; 60 private string m_username;
61 private string m_nick; 61 private string m_nick;
@@ -895,7 +895,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
895 895
896 public void Start() 896 public void Start()
897 { 897 {
898 m_scene.AddNewClient(this, PresenceType.User); 898 SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
899 899
900 // Mimicking LLClientView which gets always set appearance from client. 900 // Mimicking LLClientView which gets always set appearance from client.
901 AvatarAppearance appearance; 901 AvatarAppearance appearance;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 5ea5af7..16ec34f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
72 get { return m_ownerID; } 72 get { return m_ownerID; }
73 } 73 }
74 74
75 public ISceneAgent SceneAgent { get; set; } 75 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
76 76
77 public void Say(string message) 77 public void Say(string message)
78 { 78 {
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index d6e7200..455b51e 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -327,7 +327,7 @@ namespace OpenSim.Tests.Common.Mock
327 /// </value> 327 /// </value>
328 private UUID m_agentId; 328 private UUID m_agentId;
329 329
330 public ISceneAgent SceneAgent { get; set; } 330 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
331 331
332 /// <value> 332 /// <value>
333 /// The last caps seed url that this client was given. 333 /// The last caps seed url that this client was given.