diff options
author | Melanie Thielker | 2010-08-05 22:50:09 +0200 |
---|---|---|
committer | Melanie Thielker | 2010-08-05 22:50:09 +0200 |
commit | d8f9b98c4ab700efcf4016b605461053c3b50fba (patch) | |
tree | 471ab0e761e9378b5a07003b42dceac9f6ad38c1 /OpenSim/Region | |
parent | We already have a record of killed prims. It just wasn't used by the new (diff) | |
download | opensim-SC_OLD-d8f9b98c4ab700efcf4016b605461053c3b50fba.zip opensim-SC_OLD-d8f9b98c4ab700efcf4016b605461053c3b50fba.tar.gz opensim-SC_OLD-d8f9b98c4ab700efcf4016b605461053c3b50fba.tar.bz2 opensim-SC_OLD-d8f9b98c4ab700efcf4016b605461053c3b50fba.tar.xz |
Prevent hammering the grid services with llRequestAgentData requests. Cache the
user information permanently, and the online status for 20 seconds. Also
cache negatives.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bc47fa1..ad7d650 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -69,6 +69,14 @@ using System.Reflection; | |||
69 | 69 | ||
70 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 70 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
71 | { | 71 | { |
72 | // MUST be a ref type | ||
73 | public class UserInfoCacheEntry | ||
74 | { | ||
75 | public int time; | ||
76 | public UserAccount account; | ||
77 | public PresenceInfo pinfo; | ||
78 | } | ||
79 | |||
72 | /// <summary> | 80 | /// <summary> |
73 | /// Contains all LSL ll-functions. This class will be in Default AppDomain. | 81 | /// Contains all LSL ll-functions. This class will be in Default AppDomain. |
74 | /// </summary> | 82 | /// </summary> |
@@ -93,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
93 | protected int m_scriptConsoleChannel = 0; | 101 | protected int m_scriptConsoleChannel = 0; |
94 | protected bool m_scriptConsoleChannelEnabled = false; | 102 | protected bool m_scriptConsoleChannelEnabled = false; |
95 | protected IUrlModule m_UrlModule = null; | 103 | protected IUrlModule m_UrlModule = null; |
104 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | ||
105 | new Dictionary<UUID, UserInfoCacheEntry>(); | ||
96 | 106 | ||
97 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 107 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) |
98 | { | 108 | { |
@@ -4244,16 +4254,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4244 | m_host.AddScriptLPS(1); | 4254 | m_host.AddScriptLPS(1); |
4245 | 4255 | ||
4246 | UUID uuid = (UUID)id; | 4256 | UUID uuid = (UUID)id; |
4257 | PresenceInfo pinfo = null; | ||
4258 | UserAccount account; | ||
4247 | 4259 | ||
4248 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4260 | UserInfoCacheEntry ce; |
4249 | if (account == null) | 4261 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) |
4250 | return UUID.Zero.ToString(); | 4262 | { |
4263 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | ||
4264 | if (account == null) | ||
4265 | { | ||
4266 | m_userInfoCache[uuid] = null; // Cache negative | ||
4267 | return UUID.Zero.ToString(); | ||
4268 | } | ||
4251 | 4269 | ||
4252 | 4270 | ||
4253 | PresenceInfo pinfo = null; | 4271 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4254 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4272 | if (pinfos != null && pinfos.Length > 0) |
4255 | if (pinfos != null && pinfos.Length > 0) | 4273 | pinfo = pinfos[0]; |
4256 | pinfo = pinfos[0]; | 4274 | |
4275 | ce = new UserInfoCacheEntry(); | ||
4276 | ce.time = Util.EnvironmentTickCount(); | ||
4277 | ce.account = account; | ||
4278 | ce.pinfo = pinfo; | ||
4279 | } | ||
4280 | else | ||
4281 | { | ||
4282 | if (ce == null) | ||
4283 | return UUID.Zero.ToString(); | ||
4284 | |||
4285 | account = ce.account; | ||
4286 | pinfo = ce.pinfo; | ||
4287 | } | ||
4288 | |||
4289 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | ||
4290 | { | ||
4291 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
4292 | if (pinfos != null && pinfos.Length > 0) | ||
4293 | pinfo = pinfos[0]; | ||
4294 | |||
4295 | ce.time = Util.EnvironmentTickCount(); | ||
4296 | ce.pinfo = pinfo; | ||
4297 | } | ||
4257 | 4298 | ||
4258 | string reply = String.Empty; | 4299 | string reply = String.Empty; |
4259 | 4300 | ||