Fix the presence info caching used in llRequestAgentData(), which was completely inoperative.
This means the presence info may be out of date by up to 20 seconds, but this avoids scripts potentially triggering constants requests to user accout and presence info services. Relates to http://opensimulator.org/mantis/view.php?id=7088 though I fixed in a different way. Adds regression test for this case.0.8.0.3
parent
562a3cb338
commit
530c86335d
|
@ -40,7 +40,7 @@ namespace OpenSim.Data.Null
|
|||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static NullPresenceData Instance;
|
||||
public static NullPresenceData Instance;
|
||||
|
||||
Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>();
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public int LlRequestAgentDataCacheTimeoutMs { get; set; }
|
||||
|
||||
protected IScriptEngine m_ScriptEngine;
|
||||
protected SceneObjectPart m_host;
|
||||
|
||||
|
@ -160,25 +162,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
/// </summary>
|
||||
private void LoadConfig()
|
||||
{
|
||||
m_ScriptDelayFactor =
|
||||
m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
|
||||
m_ScriptDistanceFactor =
|
||||
m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);
|
||||
m_MinTimerInterval =
|
||||
m_ScriptEngine.Config.GetFloat("MinTimerInterval", 0.5f);
|
||||
m_automaticLinkPermission =
|
||||
m_ScriptEngine.Config.GetBoolean("AutomaticLinkPermission", false);
|
||||
m_notecardLineReadCharsMax =
|
||||
m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
|
||||
if (m_notecardLineReadCharsMax > 65535)
|
||||
m_notecardLineReadCharsMax = 65535;
|
||||
LlRequestAgentDataCacheTimeoutMs = 20000;
|
||||
|
||||
// load limits for particular subsystems.
|
||||
IConfig SMTPConfig;
|
||||
if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
|
||||
// there's an smtp config, so load in the snooze time.
|
||||
EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
|
||||
}
|
||||
IConfig seConfig = m_ScriptEngine.Config;
|
||||
|
||||
if (seConfig != null)
|
||||
{
|
||||
m_ScriptDelayFactor =
|
||||
seConfig.GetFloat("ScriptDelayFactor", m_ScriptDelayFactor);
|
||||
m_ScriptDistanceFactor =
|
||||
seConfig.GetFloat("ScriptDistanceLimitFactor", m_ScriptDistanceFactor);
|
||||
m_MinTimerInterval =
|
||||
seConfig.GetFloat("MinTimerInterval", m_MinTimerInterval);
|
||||
m_automaticLinkPermission =
|
||||
seConfig.GetBoolean("AutomaticLinkPermission", m_automaticLinkPermission);
|
||||
m_notecardLineReadCharsMax =
|
||||
seConfig.GetInt("NotecardLineReadCharsMax", m_notecardLineReadCharsMax);
|
||||
|
||||
// Rezzing an object with a velocity can create recoil. This feature seems to have been
|
||||
// removed from recent versions of SL. The code computes recoil (vel*mass) and scales
|
||||
|
@ -186,6 +185,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_recoilScaleFactor = m_ScriptEngine.Config.GetFloat("RecoilScaleFactor", m_recoilScaleFactor);
|
||||
}
|
||||
|
||||
if (m_notecardLineReadCharsMax > 65535)
|
||||
m_notecardLineReadCharsMax = 65535;
|
||||
|
||||
// load limits for particular subsystems.
|
||||
IConfigSource seConfigSource = m_ScriptEngine.ConfigSource;
|
||||
|
||||
if (seConfigSource != null)
|
||||
{
|
||||
IConfig smtpConfig = seConfigSource.Configs["SMTP"];
|
||||
if (smtpConfig != null)
|
||||
{
|
||||
// there's an smtp config, so load in the snooze time.
|
||||
EMAIL_PAUSE_TIME = smtpConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Object InitializeLifetimeService()
|
||||
{
|
||||
ILease lease = (ILease)base.InitializeLifetimeService();
|
||||
|
@ -4196,6 +4212,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
UserAccount account;
|
||||
|
||||
UserInfoCacheEntry ce;
|
||||
|
||||
lock (m_userInfoCache)
|
||||
{
|
||||
if (!m_userInfoCache.TryGetValue(uuid, out ce))
|
||||
{
|
||||
account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
|
||||
|
@ -4205,7 +4224,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return UUID.Zero.ToString();
|
||||
}
|
||||
|
||||
|
||||
PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
|
||||
if (pinfos != null && pinfos.Length > 0)
|
||||
{
|
||||
|
@ -4222,6 +4240,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
ce.time = Util.EnvironmentTickCount();
|
||||
ce.account = account;
|
||||
ce.pinfo = pinfo;
|
||||
|
||||
m_userInfoCache[uuid] = ce;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4229,10 +4249,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return UUID.Zero.ToString();
|
||||
|
||||
account = ce.account;
|
||||
pinfo = ce.pinfo;
|
||||
}
|
||||
|
||||
if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
|
||||
if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time)
|
||||
>= LlRequestAgentDataCacheTimeoutMs)
|
||||
{
|
||||
PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
|
||||
if (pinfos != null && pinfos.Length > 0)
|
||||
|
@ -4246,11 +4265,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pinfo = null;
|
||||
}
|
||||
|
||||
ce.time = Util.EnvironmentTickCount();
|
||||
ce.pinfo = pinfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
pinfo = ce.pinfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string reply = String.Empty;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Net;
|
|||
using System.Collections.Generic;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Data.Null;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Console;
|
||||
|
@ -301,6 +302,11 @@ namespace OpenSim.Tests.Common
|
|||
/// <param name="testScene"></param>
|
||||
private static LocalPresenceServicesConnector StartPresenceService()
|
||||
{
|
||||
// Unfortunately, some services share data via statics, so we need to null every time to stop interference
|
||||
// between tests.
|
||||
// This is a massive non-obvious pita.
|
||||
NullPresenceData.Instance = null;
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("Modules");
|
||||
config.AddConfig("PresenceService");
|
||||
|
|
Loading…
Reference in New Issue