From bc405a6a349f4d2be3f79afe7e8a88738339ef1f Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 13 Jul 2013 11:30:37 -0700
Subject: That didn't fix the problem.

Revert "Trying to reduce CPU usage on logins and TPs: trying radical elimination of all FireAndForgets throughout CompleteMovement. There were 4."

This reverts commit 682537738008746f0aca22954902f3a4dfbdc95f.
---
 .../Avatar/UserProfiles/UserProfileModule.cs       |  5 +-
 OpenSim/Region/Framework/Scenes/ScenePresence.cs   | 60 ++++++++++++----------
 2 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index e7216ed..c04098c 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -173,7 +173,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
             if(obj.PresenceType == PresenceType.Npc)
                 return;
 
-            GetImageAssets(((IScenePresence)obj).UUID);
+            Util.FireAndForget(delegate
+            {
+                GetImageAssets(((IScenePresence)obj).UUID);
+            });
         }
 
         /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4d796fe..9f8ada3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -958,7 +958,14 @@ namespace OpenSim.Region.Framework.Scenes
                 // Viewers which have a current outfit folder will actually rez their own attachments.  However,
                 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
                 if (Scene.AttachmentsModule != null)
-                    Scene.AttachmentsModule.RezAttachments(this); 
+                    Util.FireAndForget(
+                        o => 
+                        { 
+//                            if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) 
+//                                System.Threading.Thread.Sleep(7000); 
+
+                            Scene.AttachmentsModule.RezAttachments(this); 
+                        });
             }
             else
             {
@@ -1355,26 +1362,25 @@ namespace OpenSim.Region.Framework.Scenes
 
             ValidateAndSendAppearanceAndAgentData();
 
-            // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region
-            // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
-            // This may be due to viewer code or it may be something we're not doing properly simulator side.
-            lock (m_attachments)
-            {
-                foreach (SceneObjectGroup sog in m_attachments)
-                    sog.ScheduleGroupForFullUpdate();
-            }
-
             // Create child agents in neighbouring regions
             if (openChildAgents && !IsChildAgent)
             {
+                IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
+                if (m_agentTransfer != null)
+                    Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); });
+
                 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
                 if (friendsModule != null)
                     friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
+            }
 
-                IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
-                if (m_agentTransfer != null)
-                    m_agentTransfer.EnableChildAgents(this); // this can take a while... several seconds
-
+            // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region
+            // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
+            // This may be due to viewer code or it may be something we're not doing properly simulator side.
+            lock (m_attachments)
+            {
+                foreach (SceneObjectGroup sog in m_attachments)
+                    sog.ScheduleGroupForFullUpdate();
             }
 
 //            m_log.DebugFormat(
@@ -2683,20 +2689,22 @@ namespace OpenSim.Region.Framework.Scenes
         public void SendInitialDataToMe()
         {
             // Send all scene object to the new client
-
-            // we created a new ScenePresence (a new child agent) in a fresh region.
-            // Request info about all the (root) agents in this region
-            // Note: This won't send data *to* other clients in that region (children don't send)
-            SendOtherAgentsAvatarDataToMe();
-            SendOtherAgentsAppearanceToMe();
-
-            EntityBase[] entities = Scene.Entities.GetEntities();
-            foreach (EntityBase e in entities)
+            Util.FireAndForget(delegate
             {
-                if (e != null && e is SceneObjectGroup)
-                    ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
-            }
+                // we created a new ScenePresence (a new child agent) in a fresh region.
+                // Request info about all the (root) agents in this region
+                // Note: This won't send data *to* other clients in that region (children don't send)
+                SendOtherAgentsAvatarDataToMe();
+                SendOtherAgentsAppearanceToMe();
+
+                EntityBase[] entities = Scene.Entities.GetEntities();
+                foreach (EntityBase e in entities)
+                {
+                    if (e != null && e is SceneObjectGroup)
+                        ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
+                }
 
+            });
         }
 
         /// <summary>
-- 
cgit v1.1