aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/InventoryServer/GridInventoryService.cs
diff options
context:
space:
mode:
authorMike Mazur2008-07-25 07:16:27 +0000
committerMike Mazur2008-07-25 07:16:27 +0000
commit84cc69573bb522122606c3bc29c8ab188d4ccf70 (patch)
treeab7f7880d35e847726ee6a5102794ea4d8242928 /OpenSim/Grid/InventoryServer/GridInventoryService.cs
parentPatch #9155 (Mantis #1793) (diff)
downloadopensim-SC-84cc69573bb522122606c3bc29c8ab188d4ccf70.zip
opensim-SC-84cc69573bb522122606c3bc29c8ab188d4ccf70.tar.gz
opensim-SC-84cc69573bb522122606c3bc29c8ab188d4ccf70.tar.bz2
opensim-SC-84cc69573bb522122606c3bc29c8ab188d4ccf70.tar.xz
Thanks, lulurun, for a patch that adds an authenticated session cache to reduce
"check_auth_session" requests from inventory server to user server.
Diffstat (limited to 'OpenSim/Grid/InventoryServer/GridInventoryService.cs')
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs38
1 files changed, 27 insertions, 11 deletions
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index b8a0436..63eeced 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -38,6 +38,7 @@ using Nwc.XmlRpc;
38 38
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Cache;
41 42
42namespace OpenSim.Grid.InventoryServer 43namespace OpenSim.Grid.InventoryServer
43{ 44{
@@ -48,8 +49,10 @@ namespace OpenSim.Grid.InventoryServer
48 { 49 {
49 private static readonly ILog m_log 50 private static readonly ILog m_log
50 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs
51 53
52 private string m_userserver_url; 54 private string m_userserver_url;
55 private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME);
53 56
54 public GridInventoryService(string userserver_url) 57 public GridInventoryService(string userserver_url)
55 { 58 {
@@ -72,20 +75,33 @@ namespace OpenSim.Grid.InventoryServer
72 public bool CheckAuthSession(string session_id, string avatar_id) 75 public bool CheckAuthSession(string session_id, string avatar_id)
73 { 76 {
74 m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); 77 m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id);
75 Hashtable requestData = new Hashtable(); 78 if (m_session_cache.getCachedSession(session_id, avatar_id) == null)
76 requestData["avatar_uuid"] = avatar_id; 79 {
77 requestData["session_id"] = session_id; 80 // cache miss, ask userserver
78 ArrayList SendParams = new ArrayList(); 81 Hashtable requestData = new Hashtable();
79 SendParams.Add(requestData); 82 requestData["avatar_uuid"] = avatar_id;
80 XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); 83 requestData["session_id"] = session_id;
81 XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); 84 ArrayList SendParams = new ArrayList();
82 85 SendParams.Add(requestData);
83 Hashtable responseData = (Hashtable)UserResp.Value; 86 XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams);
84 87 XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000);
85 if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") 88
89 Hashtable responseData = (Hashtable)UserResp.Value;
90 if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE")
91 {
92 m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver");
93 // add to cache; the session time will be automatically renewed
94 m_session_cache.Add(session_id, avatar_id);
95 return true;
96 }
97 }
98 else
86 { 99 {
100 // cache hits
101 m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache");
87 return true; 102 return true;
88 } 103 }
104 m_log.Info("[GRID AGENT INVENTORY]: unknown session_id, request rejected");
89 return false; 105 return false;
90 } 106 }
91 107