mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
Merge branch 'master' into httptests
This commit is contained in:
@@ -55,9 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
protected List<string> FreezeCache = new List<string>();
|
||||
protected string m_adminPrefix = "";
|
||||
protected object m_syncy = new object();
|
||||
|
||||
protected IConfig m_config;
|
||||
|
||||
#region ISharedRegionModule Members
|
||||
public virtual void Initialise(IConfigSource config)
|
||||
{
|
||||
|
||||
@@ -455,6 +455,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
position = emergencyPos;
|
||||
}
|
||||
|
||||
// Check Default Location (Also See ScenePresence.CompleteMovement)
|
||||
if (position.X == 128f && position.Y == 128f)
|
||||
position = sp.Scene.RegionInfo.DefaultLandingPoint;
|
||||
|
||||
// TODO: Get proper AVG Height
|
||||
float localHalfAVHeight = 0.8f;
|
||||
if (sp.Appearance != null)
|
||||
@@ -594,12 +598,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
uint x = 0, y = 0;
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
|
||||
|
||||
GridRegion reg;
|
||||
|
||||
// handle legacy HG. linked regions are mapped into y = 0 and have no size information
|
||||
// so we can only search by base handle
|
||||
if( y == 0)
|
||||
{
|
||||
reg = gridService.GetRegionByPosition(scope, (int)x, (int)y);
|
||||
return reg;
|
||||
}
|
||||
|
||||
// Compute the world location we're teleporting to
|
||||
double worldX = (double)x + position.X;
|
||||
double worldY = (double)y + position.Y;
|
||||
|
||||
// Find the region that contains the position
|
||||
GridRegion reg = GetRegionContainingWorldLocation(gridService, scope, worldX, worldY);
|
||||
reg = GetRegionContainingWorldLocation(gridService, scope, worldX, worldY);
|
||||
|
||||
if (reg != null)
|
||||
{
|
||||
@@ -813,8 +827,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
if (OutSideViewRange)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for agent {3} from {4}",
|
||||
finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
|
||||
"[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} size {3},{4} needs new child agent for agent {5} from {6}",
|
||||
finalDestination.RegionName, newRegionX, newRegionY,newSizeX, newSizeY, sp.Name, Scene.Name);
|
||||
|
||||
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
|
||||
#region IP Translation for NAT
|
||||
@@ -2180,8 +2194,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
#endregion // NotFoundLocationCache class
|
||||
private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
|
||||
|
||||
// needed for old grid code
|
||||
|
||||
protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py)
|
||||
{
|
||||
// Since we don't know how big the regions could be, we have to search a very large area
|
||||
@@ -2191,6 +2203,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
// Given a world position, get the GridRegion info for
|
||||
// the region containing that point.
|
||||
// for compatibility with old grids it does a scan to find large regions
|
||||
// 0.9 grids to that
|
||||
|
||||
protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID,
|
||||
double px, double py, uint pSizeHint)
|
||||
{
|
||||
|
||||
@@ -48,31 +48,16 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly List<Scene> m_scenes = new List<Scene>();
|
||||
private System.Timers.Timer m_timer = new System.Timers.Timer();
|
||||
|
||||
private Queue<Action> m_RequestQueue = new Queue<Action>();
|
||||
private Dictionary<string, List<string>> m_Pending = new Dictionary<string, List<string>>();
|
||||
private int m_Interval;
|
||||
|
||||
private JobEngine m_processorJobEngine;
|
||||
|
||||
#region ISharedRegionModule
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
{
|
||||
m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 5000);
|
||||
|
||||
m_timer = new System.Timers.Timer();
|
||||
m_timer.AutoReset = false;
|
||||
m_timer.Enabled = true;
|
||||
m_timer.Interval = 15000; // 15 secs at first
|
||||
m_timer.Elapsed += ProcessQueue;
|
||||
m_timer.Start();
|
||||
|
||||
//WorkManager.StartThread(
|
||||
// ProcessQueue,
|
||||
// "GridServiceRequestThread",
|
||||
// ThreadPriority.BelowNormal,
|
||||
// true,
|
||||
// false);
|
||||
m_processorJobEngine = new JobEngine(
|
||||
"ServiceThrottle","ServiceThrottle");
|
||||
m_processorJobEngine.RequestProcessTimeoutOnStop = 31000; // many webrequests have 30s expire
|
||||
m_processorJobEngine.Start();
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
@@ -82,7 +67,6 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
m_scenes.Add(scene);
|
||||
scene.RegisterModuleInterface<IServiceThrottleModule>(this);
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +89,7 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_processorJobEngine.Stop();
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -126,38 +111,24 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
client.OnRegionHandleRequest += OnRegionHandleRequest;
|
||||
}
|
||||
|
||||
void OnMakeRootAgent(ScenePresence obj)
|
||||
{
|
||||
lock (m_timer)
|
||||
{
|
||||
if (!m_timer.Enabled)
|
||||
{
|
||||
m_timer.Interval = m_Interval;
|
||||
m_timer.Enabled = true;
|
||||
m_timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
|
||||
{
|
||||
//m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
|
||||
ulong handle = 0;
|
||||
if (IsLocalRegionHandle(regionID, out handle))
|
||||
{
|
||||
client.SendRegionHandle(regionID, handle);
|
||||
return;
|
||||
}
|
||||
|
||||
Action action = delegate
|
||||
{
|
||||
if(!client.IsActive)
|
||||
return;
|
||||
|
||||
GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID);
|
||||
|
||||
if(!client.IsActive)
|
||||
return;
|
||||
|
||||
if (r != null && r.RegionHandle != 0)
|
||||
client.SendRegionHandle(regionID, r.RegionHandle);
|
||||
};
|
||||
|
||||
Enqueue("region", regionID.ToString(), action);
|
||||
m_processorJobEngine.QueueJob("regionHandle", action, regionID.ToString());
|
||||
}
|
||||
|
||||
#endregion Events
|
||||
@@ -166,91 +137,10 @@ namespace OpenSim.Region.CoreModules.Framework
|
||||
|
||||
public void Enqueue(string category, string itemid, Action continuation)
|
||||
{
|
||||
lock (m_RequestQueue)
|
||||
{
|
||||
if (m_Pending.ContainsKey(category))
|
||||
{
|
||||
if (m_Pending[category].Contains(itemid))
|
||||
// Don't enqueue, it's already pending
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_Pending.Add(category, new List<string>());
|
||||
|
||||
m_Pending[category].Add(itemid);
|
||||
|
||||
m_RequestQueue.Enqueue(delegate
|
||||
{
|
||||
lock (m_RequestQueue)
|
||||
m_Pending[category].Remove(itemid);
|
||||
|
||||
continuation();
|
||||
});
|
||||
}
|
||||
m_processorJobEngine.QueueJob(category, continuation, itemid);
|
||||
}
|
||||
|
||||
#endregion IServiceThrottleModule
|
||||
|
||||
#region Process Continuation Queue
|
||||
|
||||
private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
//m_log.DebugFormat("[YYY]: Process queue with {0} continuations", m_RequestQueue.Count);
|
||||
|
||||
while (m_RequestQueue.Count > 0)
|
||||
{
|
||||
Action continuation = null;
|
||||
lock (m_RequestQueue)
|
||||
continuation = m_RequestQueue.Dequeue();
|
||||
|
||||
if (continuation != null)
|
||||
continuation();
|
||||
}
|
||||
|
||||
if (AreThereRootAgents())
|
||||
{
|
||||
lock (m_timer)
|
||||
{
|
||||
m_timer.Interval = 1000; // 1 sec
|
||||
m_timer.Enabled = true;
|
||||
m_timer.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
lock (m_timer)
|
||||
m_timer.Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
#endregion Process Continuation Queue
|
||||
|
||||
#region Misc
|
||||
|
||||
private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle)
|
||||
{
|
||||
regionHandle = 0;
|
||||
foreach (Scene s in m_scenes)
|
||||
if (s.RegionInfo.RegionID == regionID)
|
||||
{
|
||||
regionHandle = s.RegionInfo.RegionHandle;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool AreThereRootAgents()
|
||||
{
|
||||
foreach (Scene s in m_scenes)
|
||||
{
|
||||
foreach (ScenePresence sp in s.GetScenePresences())
|
||||
if (!sp.IsChildAgent)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion Misc
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
}
|
||||
|
||||
// Not found in cache, queue continuation
|
||||
m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate
|
||||
m_ServiceThrottle.Enqueue("uuidname", uuid.ToString(), delegate
|
||||
{
|
||||
//m_log.DebugFormat("[YYY]: Name request {0}", uuid);
|
||||
|
||||
@@ -216,9 +216,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
// So to avoid clients
|
||||
// (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will
|
||||
// instead drop the request entirely.
|
||||
if(!client.IsActive)
|
||||
return;
|
||||
if (GetUser(uuid, out user))
|
||||
{
|
||||
client.SendNameReply(uuid, user.FirstName, user.LastName);
|
||||
if(client.IsActive)
|
||||
client.SendNameReply(uuid, user.FirstName, user.LastName);
|
||||
}
|
||||
// else
|
||||
// m_log.DebugFormat(
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.AgentPreferences
|
||||
get { return "RemoteAgentPreferencesServicesConnector"; }
|
||||
}
|
||||
|
||||
public override void Initialise(IConfigSource source)
|
||||
public new void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig moduleConfig = source.Configs["Modules"];
|
||||
if (moduleConfig != null)
|
||||
|
||||
@@ -1801,30 +1801,51 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
{
|
||||
Hashtable hash = new Hashtable();
|
||||
hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
|
||||
if (hash.ContainsKey("region_id") && hash.ContainsKey("location"))
|
||||
if (hash.ContainsKey("location"))
|
||||
{
|
||||
UUID regionID = (UUID)hash["region_id"];
|
||||
UUID scope = m_scene.RegionInfo.ScopeID;
|
||||
ArrayList list = (ArrayList)hash["location"];
|
||||
uint x = (uint)(double)list[0];
|
||||
uint y = (uint)(double)list[1];
|
||||
if (hash.ContainsKey("region_handle"))
|
||||
if(hash.ContainsKey("region_id"))
|
||||
{
|
||||
UUID regionID = (UUID)hash["region_id"];
|
||||
if (regionID == m_scene.RegionInfo.RegionID)
|
||||
{
|
||||
// a parcel request for a local parcel => no need to query the grid
|
||||
parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// a parcel request for a parcel in another region. Ask the grid about the region
|
||||
GridRegion info = m_scene.GridService.GetRegionByUUID(scope, regionID);
|
||||
if (info != null)
|
||||
parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
else if (hash.ContainsKey("region_handle"))
|
||||
{
|
||||
// if you do a "About Landmark" on a landmark a second time, the viewer sends the
|
||||
// region_handle it got earlier via RegionHandleRequest
|
||||
ulong regionHandle = Util.BytesToUInt64Big((byte[])hash["region_handle"]);
|
||||
parcelID = Util.BuildFakeParcelID(regionHandle, x, y);
|
||||
}
|
||||
else if (regionID == m_scene.RegionInfo.RegionID)
|
||||
{
|
||||
// a parcel request for a local parcel => no need to query the grid
|
||||
parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// a parcel request for a parcel in another region. Ask the grid about the region
|
||||
GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
|
||||
if (info != null)
|
||||
parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
|
||||
if(regionHandle == m_scene.RegionInfo.RegionHandle)
|
||||
parcelID = Util.BuildFakeParcelID(regionHandle, x, y);
|
||||
else
|
||||
{
|
||||
uint wx;
|
||||
uint wy;
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out wx, out wy);
|
||||
wx += x;
|
||||
wy += y;
|
||||
GridRegion info = m_scene.GridService.GetRegionByPosition(scope, (int)wx, (int)wy);
|
||||
if(info != null)
|
||||
{
|
||||
wx -= (uint)info.RegionLocX;
|
||||
wy -= (uint)info.RegionLocY;
|
||||
parcelID = Util.BuildFakeParcelID(info.RegionHandle, wx, wy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user