Move the simulator-side RezAttachments call on login to SP.MakeRootAgent with the other attachments code, using TeleportFlags.ViaLogin check to fire if necessary.

This is to simplify the code (no tricky 'wasChild' signalling required)
and to reduce the risk of a thread clash between simulator-side attaching (necessary for v1 viewers)
and the viewer-side attaching the v3 viewers perform.
user_profiles
Justin Clark-Casey (justincc) 2013-03-28 22:07:58 +00:00
parent 9ca54d00d8
commit c2093ccce1
3 changed files with 32 additions and 39 deletions

View File

@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return; return;
} }
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);
List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments) foreach (AvatarAttachment attach in attachments)

View File

@ -2820,34 +2820,6 @@ namespace OpenSim.Region.Framework.Scenes
m_eventManager.TriggerOnNewPresence(sp); m_eventManager.TriggerOnNewPresence(sp);
sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
// The first agent upon login is a root agent by design.
// For this agent we will have to rez the attachments.
// All other AddNewClient calls find aCircuit.child to be true.
if (aCircuit.child == false)
{
// We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
// start the scripts again (since this is done in RezAttachments()).
// XXX: This is convoluted.
sp.IsChildAgent = false;
// We leave a 5 second pause before attempting to rez attachments to avoid a clash with
// version 3 viewers that maybe doing their own attachment rezzing related to their current
// outfit folder on startup. If these operations do clash, then the symptoms are invisible
// attachments until one zooms in on the avatar.
//
// We do not pause if we are launching on the same thread anyway in order to avoid pointlessly
// delaying any attachment related regression tests.
if (AttachmentsModule != null)
Util.FireAndForget(
o =>
{
if (Util.FireAndForgetMethod != FireAndForgetMethod.None)
Thread.Sleep(5000);
AttachmentsModule.RezAttachments(sp);
});
}
} }
else else
{ {

View File

@ -866,7 +866,6 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
bool wasChild = IsChildAgent;
IsChildAgent = false; IsChildAgent = false;
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
@ -952,18 +951,40 @@ namespace OpenSim.Region.Framework.Scenes
// and it has already rezzed the attachments and started their scripts. // and it has already rezzed the attachments and started their scripts.
// We do the following only for non-login agents, because their scripts // We do the following only for non-login agents, because their scripts
// haven't started yet. // haven't started yet.
lock (m_attachments) if ((TeleportFlags & TeleportFlags.ViaLogin) != 0)
{ {
if (wasChild && HasAttachments()) // We leave a 5 second pause before attempting to rez attachments to avoid a clash with
// version 3 viewers that maybe doing their own attachment rezzing related to their current
// outfit folder on startup. If these operations do clash, then the symptoms are invisible
// attachments until one zooms in on the avatar.
//
// We do not pause if we are launching on the same thread anyway in order to avoid pointlessly
// delaying any attachment related regression tests.
if (Scene.AttachmentsModule != null)
Util.FireAndForget(
o =>
{
if (Util.FireAndForgetMethod != FireAndForgetMethod.None)
System.Threading.Thread.Sleep(5000);
Scene.AttachmentsModule.RezAttachments(this);
});
}
else
{
lock (m_attachments)
{ {
m_log.DebugFormat( if (HasAttachments())
"[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
// Resume scripts
foreach (SceneObjectGroup sog in m_attachments)
{ {
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); m_log.DebugFormat(
sog.ResumeScripts(); "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
// Resume scripts
foreach (SceneObjectGroup sog in m_attachments)
{
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
sog.ResumeScripts();
}
} }
} }
} }