Merge branch 'master' into bigmerge

avinationmerge
Melanie 2011-12-09 08:13:57 +00:00
commit d913303875
12 changed files with 359 additions and 284 deletions

View File

@ -117,12 +117,10 @@
</exec> </exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindencaps.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindencaps.tests)==0}" />
<!--
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests"> <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests">
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" /> <arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
</exec> </exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" />
-->
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.scriptengine.tests"> <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.scriptengine.tests">
<arg value="./bin/OpenSim.Region.ScriptEngine.Tests.dll" /> <arg value="./bin/OpenSim.Region.ScriptEngine.Tests.dll" />
@ -351,7 +349,7 @@
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" />
<!-- <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" /> --> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.scriptengine.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.scriptengine.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.coremodules.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.coremodules.tests)==0}" />
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" /> <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" />

View File

@ -104,7 +104,7 @@ namespace OpenSim.Capabilities.Handlers
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[CAPS]: " + e.ToString()); m_log.Error("[UPLOAD BAKED TEXTURE HANDLER]: " + e.ToString());
} }
return null; return null;
@ -130,6 +130,8 @@ namespace OpenSim.Capabilities.Handlers
class BakedTextureUploader class BakedTextureUploader
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event Action<UUID, byte[]> OnUpLoad; public event Action<UUID, byte[]> OnUpLoad;
private string uploaderPath = String.Empty; private string uploaderPath = String.Empty;
@ -154,10 +156,12 @@ namespace OpenSim.Capabilities.Handlers
public string uploaderCaps(byte[] data, string path, string param) public string uploaderCaps(byte[] data, string path, string param)
{ {
Action<UUID, byte[]> handlerUpLoad = OnUpLoad; Action<UUID, byte[]> handlerUpLoad = OnUpLoad;
// Don't do this asynchronously, otherwise it's possible for the client to send set appearance information
// on another thread which might send out avatar updates before the asset has been put into the asset
// service.
if (handlerUpLoad != null) if (handlerUpLoad != null)
{ handlerUpLoad(newAssetID, data);
Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
}
string res = String.Empty; string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
@ -169,7 +173,7 @@ namespace OpenSim.Capabilities.Handlers
httpListener.RemoveStreamHandler("POST", uploaderPath); httpListener.RemoveStreamHandler("POST", uploaderPath);
// m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID); // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID);
return res; return res;
} }

View File

@ -74,9 +74,7 @@ namespace OpenSim.Framework
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="type">The type of agent to add.</param> /// <param name="type">The type of agent to add.</param>
/// <returns> /// <returns>
/// The scene agent if the new client was added. /// The scene agent if the new client was added or if an agent that already existed.</returns>
/// Null if the required scene agent already existed or no scene agent was added because the required client circuit doesn't exist.
/// </returns>
ISceneAgent AddNewClient(IClientAPI client, PresenceType type); ISceneAgent AddNewClient(IClientAPI client, PresenceType type);
/// <summary> /// <summary>

View File

@ -58,10 +58,12 @@ namespace OpenSim.Framework
/// <remarks> /// <remarks>
/// None is used to execute the method in the same thread that made the call. It should only be used by regression /// None is used to execute the method in the same thread that made the call. It should only be used by regression
/// test code that relies on predictable event ordering. /// test code that relies on predictable event ordering.
/// RegressionTest is used by regression tests. It fires the call synchronously and does not catch any exceptions.
/// </remarks> /// </remarks>
public enum FireAndForgetMethod public enum FireAndForgetMethod
{ {
None, None,
RegressionTest,
UnsafeQueueUserWorkItem, UnsafeQueueUserWorkItem,
QueueUserWorkItem, QueueUserWorkItem,
BeginInvoke, BeginInvoke,
@ -1556,27 +1558,38 @@ namespace OpenSim.Framework
public static void FireAndForget(System.Threading.WaitCallback callback, object obj) public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
{ {
// When OpenSim interacts with a database or sends data over the wire, it must send this in en_US culture WaitCallback realCallback;
// so that we don't encounter problems where, for instance, data is saved with a culture that uses commas
// for decimals places but is read by a culture that treats commas as number seperators.
WaitCallback realCallback = delegate(object o)
{
Culture.SetCurrentCulture();
try if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
{
// If we're running regression tests, then we want any exceptions to rise up to the test code.
realCallback = o => { Culture.SetCurrentCulture(); callback(o); };
}
else
{
// When OpenSim interacts with a database or sends data over the wire, it must send this in en_US culture
// so that we don't encounter problems where, for instance, data is saved with a culture that uses commas
// for decimals places but is read by a culture that treats commas as number seperators.
realCallback = o =>
{ {
callback(o); Culture.SetCurrentCulture();
}
catch (Exception e) try
{ {
m_log.ErrorFormat( callback(o);
"[UTIL]: Continuing after async_call_method thread terminated with exception {0}{1}", }
e.Message, e.StackTrace); catch (Exception e)
} {
}; m_log.ErrorFormat(
"[UTIL]: Continuing after async_call_method thread terminated with exception {0}{1}",
e.Message, e.StackTrace);
}
};
}
switch (FireAndForgetMethod) switch (FireAndForgetMethod)
{ {
case FireAndForgetMethod.RegressionTest:
case FireAndForgetMethod.None: case FireAndForgetMethod.None:
realCallback.Invoke(obj); realCallback.Invoke(obj);
break; break;

View File

@ -328,7 +328,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// The method to call if the packet is not acked by the client. If null, then a standard /// The method to call if the packet is not acked by the client. If null, then a standard
/// resend of the packet is done. /// resend of the packet is done.
/// </param> /// </param>
public void SendPacket( public virtual void SendPacket(
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
{ {
// CoarseLocationUpdate packets cannot be split in an automated way // CoarseLocationUpdate packets cannot be split in an automated way
@ -611,11 +611,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
} }
protected override void PacketReceived(UDPPacketBuffer buffer) public override void PacketReceived(UDPPacketBuffer buffer)
{ {
// Debugging/Profiling // Debugging/Profiling
//try { Thread.CurrentThread.Name = "PacketReceived (" + m_scene.RegionInfo.RegionName + ")"; } //try { Thread.CurrentThread.Name = "PacketReceived (" + m_scene.RegionInfo.RegionName + ")"; }
//catch (Exception) { } //catch (Exception) { }
// m_log.DebugFormat(
// "[LLUDPSERVER]: Packet received from {0} in {1}", buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
LLUDPClient udpClient = null; LLUDPClient udpClient = null;
Packet packet = null; Packet packet = null;
@ -625,7 +627,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Decoding #region Decoding
if (buffer.DataLength < 7) if (buffer.DataLength < 7)
{
// m_log.WarnFormat(
// "[LLUDPSERVER]: Dropping undersized packet with {0} bytes received from {1} in {2}",
// buffer.DataLength, buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
return; // Drop undersizd packet return; // Drop undersizd packet
}
int headerLen = 7; int headerLen = 7;
if (buffer.Data[6] == 0xFF) if (buffer.Data[6] == 0xFF)
@ -637,7 +645,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
if (buffer.DataLength < headerLen) if (buffer.DataLength < headerLen)
{
// m_log.WarnFormat(
// "[LLUDPSERVER]: Dropping packet with malformed header received from {0} in {1}",
// buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
return; // Malformed header return; // Malformed header
}
try try
{ {
@ -650,6 +664,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
catch (IndexOutOfRangeException) catch (IndexOutOfRangeException)
{ {
// m_log.WarnFormat(
// "[LLUDPSERVER]: Dropping short packet received from {0} in {1}",
// buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
return; // Drop short packet return; // Drop short packet
} }
catch(Exception e) catch(Exception e)
@ -887,29 +905,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// DateTime startTime = DateTime.Now; // DateTime startTime = DateTime.Now;
object[] array = (object[])o; object[] array = (object[])o;
UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint); m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint);
IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
// Begin the process of adding the client to the simulator AuthenticateResponse sessionInfo;
IClientAPI client = AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); if (IsClientAuthorized(uccp, out sessionInfo))
{
// Send ack straight away to let the viewer know that the connection is active. // Begin the process of adding the client to the simulator
SendAckImmediate(remoteEndPoint, packet.Header.Sequence); IClientAPI client
= AddClient(
// FIXME: Nasty - this is the only way we currently know if Scene.AddNewClient() failed to find a uccp.CircuitCode.Code,
// circuit and bombed out early. That check might be pointless since authorization is established uccp.CircuitCode.ID,
// up here. uccp.CircuitCode.SessionID,
if (client != null && client.SceneAgent != null) remoteEndPoint,
client.SceneAgent.SendInitialDataToMe(); sessionInfo);
// Send ack straight away to let the viewer know that the connection is active.
// The client will be null if it already exists (e.g. if on a region crossing the client sends a use
// circuit code to the existing child agent. This is not particularly obvious.
SendAckImmediate(remoteEndPoint, uccp.Header.Sequence);
// We only want to send initial data to new clients, not ones which are being converted from child to root.
if (client != null)
client.SceneAgent.SendInitialDataToMe();
}
else
{
// Don't create clients for unauthorized requesters.
m_log.WarnFormat(
"[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
uccp.CircuitCode.ID, uccp.CircuitCode.Code, remoteEndPoint);
}
// m_log.DebugFormat( // m_log.DebugFormat(
// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", // "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); // buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
} }
/// <summary>
/// Send an ack immediately to the given endpoint.
/// </summary>
/// <remarks>
/// FIXME: Might be possible to use SendPacketData() like everything else, but this will require refactoring so
/// that we can obtain the UDPClient easily at this point.
/// </remarks>
/// <param name="remoteEndpoint"></param>
/// <param name="sequenceNumber"></param>
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber) private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
{ {
PacketAckPacket ack = new PacketAckPacket(); PacketAckPacket ack = new PacketAckPacket();
@ -918,6 +962,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ack.Packets[0] = new PacketAckPacket.PacketsBlock(); ack.Packets[0] = new PacketAckPacket.PacketsBlock();
ack.Packets[0].ID = sequenceNumber; ack.Packets[0].ID = sequenceNumber;
SendAckImmediate(remoteEndpoint, ack);
}
public virtual void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
{
byte[] packetData = ack.ToBytes(); byte[] packetData = ack.ToBytes();
int length = packetData.Length; int length = packetData.Length;
@ -939,36 +988,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return sessionInfo.Authorised; return sessionInfo.Authorised;
} }
/// <summary>
/// Add a new client.
/// </summary>
/// <param name="useCircuitCode"></param>
/// <param name="remoteEndPoint"></param>
/// <returns>
/// The client that was added or null if the client failed authorization or already existed.
/// </returns>
private IClientAPI AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
{
UUID agentID = useCircuitCode.CircuitCode.ID;
UUID sessionID = useCircuitCode.CircuitCode.SessionID;
uint circuitCode = useCircuitCode.CircuitCode.Code;
AuthenticateResponse sessionInfo;
if (IsClientAuthorized(useCircuitCode, out sessionInfo))
{
return AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
}
else
{
// Don't create circuits for unauthorized clients
m_log.WarnFormat(
"[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
return null;
}
}
/// <summary> /// <summary>
/// Add a client. /// Add a client.
/// </summary> /// </summary>

View File

@ -44,7 +44,7 @@ namespace OpenMetaverse
/// This method is called when an incoming packet is received /// This method is called when an incoming packet is received
/// </summary> /// </summary>
/// <param name="buffer">Incoming packet buffer</param> /// <param name="buffer">Incoming packet buffer</param>
protected abstract void PacketReceived(UDPPacketBuffer buffer); public abstract void PacketReceived(UDPPacketBuffer buffer);
/// <summary>UDP port to bind to in server mode</summary> /// <summary>UDP port to bind to in server mode</summary>
protected int m_udpPort; protected int m_udpPort;

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Net; using System.Net;
using log4net.Config; using log4net.Config;
using Nini.Config; using Nini.Config;
@ -32,6 +33,7 @@ using NUnit.Framework;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
@ -43,19 +45,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
[TestFixture] [TestFixture]
public class BasicCircuitTests public class BasicCircuitTests
{ {
[SetUp] [TestFixtureSetUp]
public void Init() public void FixtureInit()
{ {
try // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
{ Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
XmlConfigurator.Configure();
}
catch
{
// I don't care, just leave log4net off
}
} }
[TestFixtureTearDown]
public void TearDown()
{
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
// threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
// tests really shouldn't).
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
}
// /// <summary> // /// <summary>
// /// Add a client for testing // /// Add a client for testing
// /// </summary> // /// </summary>
@ -78,54 +83,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
// testLLUDPServer.LocalScene = scene; // testLLUDPServer.LocalScene = scene;
// } // }
/// <summary> // /// <summary>
/// Set up a client for tests which aren't concerned with this process itself and where only one client is being // /// Set up a client for tests which aren't concerned with this process itself and where only one client is being
/// tested // /// tested
/// </summary> // /// </summary>
/// <param name="circuitCode"></param> // /// <param name="circuitCode"></param>
/// <param name="epSender"></param> // /// <param name="epSender"></param>
/// <param name="testLLUDPServer"></param> // /// <param name="testLLUDPServer"></param>
/// <param name="acm"></param> // /// <param name="acm"></param>
protected void AddClient( // protected void AddClient(
uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) // uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
{ // {
UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); // UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); // UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
//
AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm); // AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm);
} // }
/// <summary> // /// <summary>
/// Set up a client for tests which aren't concerned with this process itself // /// Set up a client for tests which aren't concerned with this process itself
/// </summary> // /// </summary>
/// <param name="circuitCode"></param> // /// <param name="circuitCode"></param>
/// <param name="epSender"></param> // /// <param name="epSender"></param>
/// <param name="agentId"></param> // /// <param name="agentId"></param>
/// <param name="sessionId"></param> // /// <param name="sessionId"></param>
/// <param name="testLLUDPServer"></param> // /// <param name="testLLUDPServer"></param>
/// <param name="acm"></param> // /// <param name="acm"></param>
protected void AddClient( // protected void AddClient(
uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId, // uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId,
TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) // TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
{ // {
AgentCircuitData acd = new AgentCircuitData(); // AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = agentId; // acd.AgentID = agentId;
acd.SessionID = sessionId; // acd.SessionID = sessionId;
//
UseCircuitCodePacket uccp = new UseCircuitCodePacket(); // UseCircuitCodePacket uccp = new UseCircuitCodePacket();
//
UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock // UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
= new UseCircuitCodePacket.CircuitCodeBlock(); // = new UseCircuitCodePacket.CircuitCodeBlock();
uccpCcBlock.Code = circuitCode; // uccpCcBlock.Code = circuitCode;
uccpCcBlock.ID = agentId; // uccpCcBlock.ID = agentId;
uccpCcBlock.SessionID = sessionId; // uccpCcBlock.SessionID = sessionId;
uccp.CircuitCode = uccpCcBlock; // uccp.CircuitCode = uccpCcBlock;
//
acm.AddNewCircuit(circuitCode, acd); // acm.AddNewCircuit(circuitCode, acd);
//
testLLUDPServer.LoadReceive(uccp, epSender); // testLLUDPServer.LoadReceive(uccp, epSender);
testLLUDPServer.ReceiveData(null); // testLLUDPServer.ReceiveData(null);
} // }
/// <summary> /// <summary>
/// Build an object name packet for test purposes /// Build an object name packet for test purposes
@ -144,54 +149,69 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
return onp; return onp;
} }
// /// <summary> /// <summary>
// /// Test adding a client to the stack /// Test adding a client to the stack
// /// </summary> /// </summary>
// [Test] [Test]
// public void TestAddClient() public void TestAddClient()
// { {
// TestHelper.InMethod(); TestHelpers.InMethod();
// // XmlConfigurator.Configure();
// uint myCircuitCode = 123456;
// UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); TestScene scene = SceneHelpers.SetupScene();
// UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); uint myCircuitCode = 123456;
// UUID myAgentUuid = TestHelpers.ParseTail(0x1);
// TestLLUDPServer testLLUDPServer; UUID mySessionUuid = TestHelpers.ParseTail(0x2);
// TestLLPacketServer testLLPacketServer; IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
// AgentCircuitManager acm;
// SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); uint port = 0;
// AgentCircuitManager acm = scene.AuthenticateHandler;
// AgentCircuitData acd = new AgentCircuitData();
// acd.AgentID = myAgentUuid; TestLLUDPServer llUdpServer
// acd.SessionID = mySessionUuid; = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
// llUdpServer.AddScene(scene);
// UseCircuitCodePacket uccp = new UseCircuitCodePacket();
// UseCircuitCodePacket uccp = new UseCircuitCodePacket();
// UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
// = new UseCircuitCodePacket.CircuitCodeBlock(); UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
// uccpCcBlock.Code = myCircuitCode; = new UseCircuitCodePacket.CircuitCodeBlock();
// uccpCcBlock.ID = myAgentUuid; uccpCcBlock.Code = myCircuitCode;
// uccpCcBlock.SessionID = mySessionUuid; uccpCcBlock.ID = myAgentUuid;
// uccp.CircuitCode = uccpCcBlock; uccpCcBlock.SessionID = mySessionUuid;
// uccp.CircuitCode = uccpCcBlock;
// EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
// byte[] uccpBytes = uccp.ToBytes();
// testLLUDPServer.LoadReceive(uccp, testEp); UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length);
// testLLUDPServer.ReceiveData(null); upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
// Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
// // Circuit shouildn't exist since the circuit manager doesn't know about this circuit for authentication yet
// Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); llUdpServer.PacketReceived(upb);
//
// acm.AddNewCircuit(myCircuitCode, acd); // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet
// Assert.That(scene.GetScenePresence(myAgentUuid), Is.Null);
// testLLUDPServer.LoadReceive(uccp, testEp);
// testLLUDPServer.ReceiveData(null); AgentCircuitData acd = new AgentCircuitData();
// acd.AgentID = myAgentUuid;
// // Should succeed now acd.SessionID = mySessionUuid;
// Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode));
// Assert.IsFalse(testLLUDPServer.HasCircuit(101)); acm.AddNewCircuit(myCircuitCode, acd);
// }
// llUdpServer.PacketReceived(upb);
// Should succeed now
ScenePresence sp = scene.GetScenePresence(myAgentUuid);
Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1));
Packet packet = llUdpServer.PacketsSent[0];
Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));
PacketAckPacket ackPacket = packet as PacketAckPacket;
Assert.That(ackPacket.Packets.Length, Is.EqualTo(1));
Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0));
}
// /// <summary> // /// <summary>
// /// Test removing a client from the stack // /// Test removing a client from the stack
// /// </summary> // /// </summary>

View File

@ -36,107 +36,106 @@ using OpenSim.Framework;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{ {
/// <summary> /// <summary>
/// This class enables synchronous testing of the LLUDPServer by allowing us to load our own data into the end /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
/// receive event
/// </summary> /// </summary>
public class TestLLUDPServer : LLUDPServer public class TestLLUDPServer : LLUDPServer
{ {
public List<Packet> PacketsSent { get; private set; }
public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
: base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager) : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
{} {
PacketsSent = new List<Packet>();
}
/// <summary> public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
/// The chunks of data to pass to the LLUDPServer when it calls EndReceive
/// </summary>
protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
// protected override void BeginReceive()
// {
// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
// {
// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
// reusedEpSender = tuple.Sender;
// throw new SocketException();
// }
// }
// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
// {
// numBytes = 0;
//
// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
//
// if (m_chunksToLoad.Count <= 0)
// return false;
//
// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
// RecvBuffer = tuple.Data;
// numBytes = tuple.Data.Length;
// epSender = tuple.Sender;
//
// return true;
// }
// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
// {
// // Don't do anything just yet
// }
/// <summary>
/// Signal that this chunk should throw an exception on Socket.BeginReceive()
/// </summary>
/// <param name="epSender"></param>
public void LoadReceiveWithBeginException(EndPoint epSender)
{ {
ChunkSenderTuple tuple = new ChunkSenderTuple(epSender); PacketsSent.Add(ack);
tuple.BeginReceiveException = true;
m_chunksToLoad.Enqueue(tuple);
} }
/// <summary>
/// Load some data to be received by the LLUDPServer on the next receive call
/// </summary>
/// <param name="data"></param>
/// <param name="epSender"></param>
public void LoadReceive(byte[] data, EndPoint epSender)
{
m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
}
/// <summary>
/// Load a packet to be received by the LLUDPServer on the next receive call
/// </summary>
/// <param name="packet"></param>
public void LoadReceive(Packet packet, EndPoint epSender)
{
LoadReceive(packet.ToBytes(), epSender);
}
/// <summary>
/// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
/// </summary>
/// <param name="result"></param>
public void ReceiveData(IAsyncResult result)
{
// Doesn't work the same way anymore
// while (m_chunksToLoad.Count > 0)
// OnReceivedData(result);
}
/// <summary>
/// Has a circuit with the given code been established?
/// </summary>
/// <param name="circuitCode"></param>
/// <returns></returns>
public bool HasCircuit(uint circuitCode)
{
// lock (clientCircuits_reverse)
// {
// return clientCircuits_reverse.ContainsKey(circuitCode);
// }
return true; public override void SendPacket(
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
{
PacketsSent.Add(packet);
} }
//// /// <summary>
//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
//// /// </summary>
//// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
//
//// protected override void BeginReceive()
//// {
//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
//// {
//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
//// reusedEpSender = tuple.Sender;
//// throw new SocketException();
//// }
//// }
//
//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
//// {
//// numBytes = 0;
////
//// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
////
//// if (m_chunksToLoad.Count <= 0)
//// return false;
////
//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
//// RecvBuffer = tuple.Data;
//// numBytes = tuple.Data.Length;
//// epSender = tuple.Sender;
////
//// return true;
//// }
//
//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
//// {
//// // Don't do anything just yet
//// }
//
// /// <summary>
// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
// /// </summary>
// /// <param name="epSender"></param>
// public void LoadReceiveWithBeginException(EndPoint epSender)
// {
// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
// tuple.BeginReceiveException = true;
// m_chunksToLoad.Enqueue(tuple);
// }
//
// /// <summary>
// /// Load some data to be received by the LLUDPServer on the next receive call
// /// </summary>
// /// <param name="data"></param>
// /// <param name="epSender"></param>
// public void LoadReceive(byte[] data, EndPoint epSender)
// {
// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
// }
//
// /// <summary>
// /// Load a packet to be received by the LLUDPServer on the next receive call
// /// </summary>
// /// <param name="packet"></param>
// public void LoadReceive(Packet packet, EndPoint epSender)
// {
// LoadReceive(packet.ToBytes(), epSender);
// }
//
// /// <summary>
// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
// /// </summary>
// /// <param name="result"></param>
// public void ReceiveData(IAsyncResult result)
// {
// // Doesn't work the same way anymore
//// while (m_chunksToLoad.Count > 0)
//// OnReceivedData(result);
// }
} }
/// <summary> /// <summary>

View File

@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public int m_animTickJump; // ScenePresence has to see this to control +Z force public int m_animTickJump; // ScenePresence has to see this to control +Z force
public bool m_jumping = false; public bool m_jumping = false;
public float m_jumpVelocity = 0f; public float m_jumpVelocity = 0f;
private int m_landing = 0; // private int m_landing = 0;
public bool Falling public bool Falling
{ {
get { return m_falling; } get { return m_falling; }

View File

@ -2609,21 +2609,14 @@ namespace OpenSim.Region.Framework.Scenes
#region Add/Remove Avatar Methods #region Add/Remove Avatar Methods
/// <summary>
/// Add a new client and create a child scene presence for it.
/// </summary>
/// <param name="client"></param>
/// <param name="type">The type of agent to add.</param>
public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type)
{ {
// Validation occurs in LLUDPServer
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
bool vialogin = false;
if (aCircuit == null) // no good, didn't pass NewUserConnection successfully bool vialogin
return null; = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
|| (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 ||
(aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
CheckHeartbeat(); CheckHeartbeat();
ScenePresence presence; ScenePresence presence;

View File

@ -2397,8 +2397,6 @@ namespace OpenSim.Region.Framework.Scenes
#region Overridden Methods #region Overridden Methods
private bool sendingPrims = false;
public override void Update() public override void Update()
{ {
const float ROTATION_TOLERANCE = 0.01f; const float ROTATION_TOLERANCE = 0.01f;
@ -2569,7 +2567,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
// This agent just became root. We are going to tell everyone about it. The process of // This agent just became root. We are going to tell everyone about it. The process of
// getting other avatars information was initiated in the constructor... don't do it // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it
// again here... this comes after the cached appearance check because the avatars // again here... this comes after the cached appearance check because the avatars
// appearance goes into the avatar update packet // appearance goes into the avatar update packet
SendAvatarDataToAllAgents(); SendAvatarDataToAllAgents();

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<log4net>
<!-- A1 is set to be a ConsoleAppender -->
<appender name="A1" type="log4net.Appender.ConsoleAppender">
<!-- A1 uses PatternLayout -->
<layout type="log4net.Layout.PatternLayout">
<!-- Print the date in ISO 8601 format -->
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
</layout>
</appender>
<!-- Set root logger level to DEBUG and its only appender to A1 -->
<root>
<level value="DEBUG" />
<appender-ref ref="A1" />
</root>
</log4net>
</configuration>