diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 21640cf947..c266fe58ca 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -29,6 +29,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
+using System.Threading;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
@@ -856,7 +857,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
IClientAPI friendClient = LocateClientObject(friendID);
if (friendClient != null)
{
- // the friend in this sim as root agent
+ // the friend in this sim as root agent
if (online)
friendClient.SendAgentOnline(new UUID[] { userID });
else
@@ -913,6 +914,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private void RecacheFriends(IClientAPI client)
{
+ // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
+ // is on the critical path for transferring an avatar from one region to another.
UUID agentID = client.AgentId;
lock (m_Friends)
{
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index bf9ad65b22..4906665cbe 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -212,10 +212,15 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void OnMakeChildAgentDelegate(ScenePresence presence);
public event OnMakeChildAgentDelegate OnMakeChildAgent;
- public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
public delegate void OnSaveNewWindlightProfileDelegate();
public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user);
- public event OnMakeRootAgentDelegate OnMakeRootAgent;
+
+ ///
+ /// This event is on the critical path for transferring an avatar from one region to another. Try and do
+ /// as little work on this event as possible, or do work asynchronously.
+ ///
+ public event Action OnMakeRootAgent;
+
public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
@@ -1322,10 +1327,10 @@ namespace OpenSim.Region.Framework.Scenes
public void TriggerOnMakeRootAgent(ScenePresence presence)
{
- OnMakeRootAgentDelegate handlerMakeRootAgent = OnMakeRootAgent;
+ Action handlerMakeRootAgent = OnMakeRootAgent;
if (handlerMakeRootAgent != null)
{
- foreach (OnMakeRootAgentDelegate d in handlerMakeRootAgent.GetInvocationList())
+ foreach (Action d in handlerMakeRootAgent.GetInvocationList())
{
try
{
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 189394e38f..5587073881 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -865,6 +865,9 @@ namespace OpenSim.Region.Framework.Scenes
/// avatar is actual in the sim. They can perform all actions.
/// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim,
/// teleporting in or on initial login.
+ ///
+ /// This method is on the critical path for transferring an avatar from one region to another. Delay here
+ /// delays that crossing.
///
public void MakeRootAgent(Vector3 pos, bool isFlying)
{