diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs index d55f423a1e..6210d0c378 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs @@ -112,6 +112,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests testLLUDPServer.ReceiveData(null); } + /// + /// Build an object name packet for test purposes + /// + /// + /// + protected ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) + { + ObjectNamePacket onp = new ObjectNamePacket(); + ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); + odb.LocalID = objectLocalId; + odb.Name = Utils.StringToBytes(objectName); + onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb }; + onp.Header.Zerocoded = false; + + return onp; + } + /// /// Test adding a client to the stack /// @@ -209,19 +226,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests // Check that sending a valid packet to same circuit still succeeds Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0)); - - ObjectNamePacket onp = new ObjectNamePacket(); - ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); - odb.LocalID = 1; - odb.Name = Utils.StringToBytes("helloooo"); - onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb }; - onp.Header.Zerocoded = false; - testLLUDPServer.LoadReceive(onp, testEp); + testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp); testLLUDPServer.ReceiveData(null); Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1)); Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1)); } + + /// + /// Test that the stack continues to work even if some client has caused a + /// SocketException on Socket.BeginReceive() + /// + [Test] + public void TestExceptionOnBeginReceive() + { + /* + MockScene scene = new MockScene(); + + uint circuitCodeA = 130000; + EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300); + uint circuitCodeB = 130001; + EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301); + + TestLLUDPServer testLLUDPServer; + TestLLPacketServer testLLPacketServer; + AgentCircuitManager acm; + SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); + AddClient(circuitCodeA, epA, testLLUDPServer, acm); + AddClient(circuitCodeB, epB, testLLUDPServer, acm); + */ + } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs index dd7afd3565..002b493006 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs @@ -48,7 +48,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests protected override void BeginReceive() { - // Do nothing + 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) @@ -71,6 +76,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests // Don't do anything just yet } + /// + /// Signal that this chunk should throw an exception on Socket.BeginReceive() + /// + /// + public void LoadReceiveWithBeginException(EndPoint epSender) + { + ChunkSenderTuple tuple = new ChunkSenderTuple(epSender); + tuple.BeginReceiveException = true; + m_chunksToLoad.Enqueue(tuple); + } + /// /// Load some data to be received by the LLUDPServer on the next receive call /// @@ -118,14 +134,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests /// Record the data and sender tuple /// public class ChunkSenderTuple - { + { public byte[] Data; public EndPoint Sender; + public bool BeginReceiveException; public ChunkSenderTuple(byte[] data, EndPoint sender) { Data = data; Sender = sender; } + + public ChunkSenderTuple(EndPoint sender) + { + Sender = sender; + } } } \ No newline at end of file