Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-08-18 00:59:20 +01:00
66 changed files with 1121 additions and 595 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -174,9 +174,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
position.Z = newPosZ;
}
// Only send this if the event queue is null
if (eq == null)
sp.ControllingClient.SendTeleportLocationStart();
sp.ControllingClient.SendTeleportStart(teleportFlags);
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.Teleport(position);
@@ -257,9 +255,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
ulong destinationHandle = finalDestination.RegionHandle;
if (eq == null)
sp.ControllingClient.SendTeleportLocationStart();
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
@@ -277,6 +272,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return;
}
sp.ControllingClient.SendTeleportStart(teleportFlags);
// the avatar.Close below will clear the child region list. We need this below for (possibly)
// closing the child agents, so save it here (we need a copy as it is Clear()-ed).
//List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
@@ -307,7 +304,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
string reason = String.Empty;
// Let's create an agent there if one doesn't exist yet.
if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason))
bool logout = false;
if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
{
sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
reason));
@@ -319,6 +317,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT
IClientIPEndpoint ipepClient;
if (sp.ClientView.TryGet(out ipepClient))
@@ -396,6 +396,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.Position = position;
SetCallbackURL(agent, sp.Scene.RegionInfo);
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent...");
if (!UpdateAgent(reg, finalDestination, agent))
{
// Region doesn't take it
@@ -434,8 +436,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
// Well, this is it. The agent is over there.
KillEntity(sp.Scene, sp.LocalId);
// May need to logout or other cleanup
AgentHasMovedAway(sp.ControllingClient.SessionId, logout);
// Now let's make it officially a child agent
sp.MakeChildAgent();
@@ -483,8 +490,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
{
logout = false;
return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
}
@@ -500,6 +508,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
protected virtual void AgentHasMovedAway(UUID sessionID, bool logout)
{
}
protected void KillEntity(Scene scene, uint localID)
{
scene.SendKillObject(localID);
@@ -1286,18 +1298,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return handles;
}
private void Dump(string msg, List<ulong> handles)
{
m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
foreach (ulong handle in handles)
{
uint x, y;
Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
m_log.InfoFormat("({0}, {1})", x, y);
}
}
// private void Dump(string msg, List<ulong> handles)
// {
// m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
// foreach (ulong handle in handles)
// {
// uint x, y;
// Utils.LongToUInts(handle, out x, out y);
// x = x / Constants.RegionSize;
// y = y / Constants.RegionSize;
// m_log.InfoFormat("({0}, {1})", x, y);
// }
// }
#endregion

View File

@@ -140,9 +140,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return false;
}
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
protected override void AgentHasMovedAway(UUID sessionID, bool logout)
{
if (logout)
// Log them out of this grid
m_aScene.PresenceService.LogoutAgent(sessionID);
}
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
{
reason = string.Empty;
logout = false;
int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
{
@@ -152,9 +160,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
if (success)
// Log them out of this grid
m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID);
logout = success; // flag for later logout from this grid; this is an HG TP
return success;
}

View File

@@ -54,12 +54,10 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
}
private static byte[] uintToByteArray(uint uIntValue)
{
byte[] resultbytes = Utils.UIntToBytes(uIntValue);
if (BitConverter.IsLittleEndian)
Array.Reverse(resultbytes);
return resultbytes;
{
byte[] result = new byte[4];
Utils.UIntToBytesBig(uIntValue, result, 0);
return result;
}
public static OSD buildEvent(string eventName, OSD eventBody)
@@ -160,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
info.Add("SimAccess", OSD.FromInteger(simAccess));
info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes()));
info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port));
info.Add("TeleportFlags", OSD.FromBinary(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
OSDArray infoArr = new OSDArray();
infoArr.Add(info);

View File

@@ -95,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
try
{
asset1.ID = url + "/" + asset.ID;
UUID temp = UUID.Zero;
// UUID temp = UUID.Zero;
// TODO: if the creator is local, stick this grid's URL in front
//if (UUID.TryParse(asset.Metadata.CreatorID, out temp))
// asset1.Metadata.CreatorID = ??? + "/" + asset.Metadata.CreatorID;

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
get { return m_assMapper; }
}
private bool m_Initialized = false;
// private bool m_Initialized = false;
#region INonSharedRegionModule

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -572,7 +572,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
if (attachment)
{
group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
group.RootPart.Flags |= PrimFlags.Phantom;
group.RootPart.IsAttachment = true;
}

View File

@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
private static bool m_HasRunOnce = false;
private bool m_Enabled = false;
private string m_LibraryName = "OpenSim Library";
// private string m_LibraryName = "OpenSim Library";
private Scene m_Scene;
private ILibraryService m_Library;
@@ -212,13 +212,13 @@ namespace OpenSim.Region.CoreModules.Framework.Library
}
}
private void DumpLibrary()
{
InventoryFolderImpl lib = m_Library.LibraryRootFolder;
m_log.DebugFormat(" - folder {0}", lib.Name);
DumpFolder(lib);
}
// private void DumpLibrary()
// {
// InventoryFolderImpl lib = m_Library.LibraryRootFolder;
//
// m_log.DebugFormat(" - folder {0}", lib.Name);
// DumpFolder(lib);
// }
//
// private void DumpLibrary()
// {

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BinaryLoggingModule")]
public class BinaryLoggingModule : INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected bool m_collectStats;
protected Scene m_scene = null;
public string Name { get { return "Binary Statistics Logging Module"; } }
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source)
{
try
{
IConfig statConfig = source.Configs["Statistics.Binary"];
if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled"))
{
if (statConfig.Contains("collect_region_stats"))
{
if (statConfig.GetBoolean("collect_region_stats"))
{
m_collectStats = true;
}
}
if (statConfig.Contains("region_stats_period_seconds"))
{
m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds"));
}
if (statConfig.Contains("stats_dir"))
{
m_statsDir = statConfig.GetString("stats_dir");
}
}
}
catch
{
// if it doesn't work, we don't collect anything
}
}
public void AddRegion(Scene scene)
{
m_scene = scene;
}
public void RemoveRegion(Scene scene)
{
}
public void RegionLoaded(Scene scene)
{
if (m_collectStats)
m_scene.StatsReporter.OnSendStatsResult += LogSimStats;
}
public void Close()
{
}
public class StatLogger
{
public DateTime StartTime;
public string Path;
public System.IO.BinaryWriter Log;
}
static StatLogger m_statLog = null;
static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300);
static string m_statsDir = String.Empty;
static Object m_statLockObject = new Object();
private void LogSimStats(SimStats stats)
{
SimStatsPacket pack = new SimStatsPacket();
pack.Region = new SimStatsPacket.RegionBlock();
pack.Region.RegionX = stats.RegionX;
pack.Region.RegionY = stats.RegionY;
pack.Region.RegionFlags = stats.RegionFlags;
pack.Region.ObjectCapacity = stats.ObjectCapacity;
//pack.Region = //stats.RegionBlock;
pack.Stat = stats.StatsBlock;
pack.Header.Reliable = false;
// note that we are inside the reporter lock when called
DateTime now = DateTime.Now;
// hide some time information into the packet
pack.Header.Sequence = (uint)now.Ticks;
lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here
{
try
{
if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod)
{
// First log file or time has expired, start writing to a new log file
if (m_statLog != null && m_statLog.Log != null)
{
m_statLog.Log.Close();
}
m_statLog = new StatLogger();
m_statLog.StartTime = now;
m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "")
+ String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss"));
m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write));
}
// Write the serialized data to disk
if (m_statLog != null && m_statLog.Log != null)
m_statLog.Log.Write(pack.ToBytes());
}
catch (Exception ex)
{
m_log.Error("statistics gathering failed: " + ex.Message, ex);
if (m_statLog != null && m_statLog.Log != null)
{
m_statLog.Log.Close();
}
m_statLog = null;
}
}
return;
}
}
}