aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-11-06 19:35:57 +0000
committerJustin Clarke Casey2008-11-06 19:35:57 +0000
commit29691a3d36906c27b7fd7955184106bd6178cb83 (patch)
tree699b590bed419108729d19e519434225f78953c3 /OpenSim/Region/ClientStack/LindenUDP
parentMantis#2566. Thank you kindly, Diva for a patch that: (diff)
downloadopensim-SC-29691a3d36906c27b7fd7955184106bd6178cb83.zip
opensim-SC-29691a3d36906c27b7fd7955184106bd6178cb83.tar.gz
opensim-SC-29691a3d36906c27b7fd7955184106bd6178cb83.tar.bz2
opensim-SC-29691a3d36906c27b7fd7955184106bd6178cb83.tar.xz
* Test to ensure that the udp server stays active after receiving a SocketException on BeginReceive
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs54
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs7
3 files changed, 50 insertions, 16 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 65e8b5f..ffb3d1d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -263,7 +263,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
263 if (ret) 263 if (ret)
264 { 264 {
265 //if so then send packet to the packetserver 265 //if so then send packet to the packetserver
266 //m_log.DebugFormat("[UDPSERVER]: For endpoint {0} got packet {1}", epSender, packet.Type); 266 //m_log.DebugFormat(
267 // "[UDPSERVER]: For circuit {0} {1} got packet {2}", circuit, epSender, packet.Type);
267 268
268 m_packetServer.InPacket(circuit, packet); 269 m_packetServer.InPacket(circuit, packet);
269 } 270 }
@@ -300,7 +301,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
300 /// <param name="e"> 301 /// <param name="e">
301 /// The exception that has triggered the reset. Can be null if there was no exception. 302 /// The exception that has triggered the reset. Can be null if there was no exception.
302 /// </param> 303 /// </param>
303 private void ResetServerEndPoint(Exception e) 304 protected void ResetServerEndPoint(Exception e)
304 { 305 {
305 try 306 try
306 { 307 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
index 6210d0c..dc1c63d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System.Net; 28using System.Net;
29using System.Threading;
29using log4net; 30using log4net;
30using Nini.Config; 31using Nini.Config;
31using NUnit.Framework; 32using NUnit.Framework;
@@ -81,7 +82,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
81 } 82 }
82 83
83 /// <summary> 84 /// <summary>
84 /// Set up a client for tests which aren't concerned with this process itself 85 /// Set up a client for tests which aren't concerned with this process itself and where only one client is being
86 /// tested
85 /// </summary> 87 /// </summary>
86 /// <param name="circuitCode"></param> 88 /// <param name="circuitCode"></param>
87 /// <param name="epSender"></param> 89 /// <param name="epSender"></param>
@@ -92,18 +94,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
92 { 94 {
93 UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); 95 UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
94 UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); 96 UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
95 97
98 AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm);
99 }
100
101 /// <summary>
102 /// Set up a client for tests which aren't concerned with this process itself
103 /// </summary>
104 /// <param name="circuitCode"></param>
105 /// <param name="epSender"></param>
106 /// <param name="agentId"></param>
107 /// <param name="sessionId"></param>
108 /// <param name="testLLUDPServer"></param>
109 /// <param name="acm"></param>
110 protected void AddClient(
111 uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId,
112 TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
113 {
96 AgentCircuitData acd = new AgentCircuitData(); 114 AgentCircuitData acd = new AgentCircuitData();
97 acd.AgentID = myAgentUuid; 115 acd.AgentID = agentId;
98 acd.SessionID = mySessionUuid; 116 acd.SessionID = sessionId;
99 117
100 UseCircuitCodePacket uccp = new UseCircuitCodePacket(); 118 UseCircuitCodePacket uccp = new UseCircuitCodePacket();
101 119
102 UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock 120 UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
103 = new OpenMetaverse.Packets.UseCircuitCodePacket.CircuitCodeBlock(); 121 = new OpenMetaverse.Packets.UseCircuitCodePacket.CircuitCodeBlock();
104 uccpCcBlock.Code = circuitCode; 122 uccpCcBlock.Code = circuitCode;
105 uccpCcBlock.ID = myAgentUuid; 123 uccpCcBlock.ID = agentId;
106 uccpCcBlock.SessionID = mySessionUuid; 124 uccpCcBlock.SessionID = sessionId;
107 uccp.CircuitCode = uccpCcBlock; 125 uccp.CircuitCode = uccpCcBlock;
108 126
109 acm.AddNewCircuit(circuitCode, acd); 127 acm.AddNewCircuit(circuitCode, acd);
@@ -181,7 +199,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
181 [Test] 199 [Test]
182 public void TestRemoveClient() 200 public void TestRemoveClient()
183 { 201 {
184 uint myCircuitCode = 123457; 202 uint myCircuitCode = 123457;
185 203
186 TestLLUDPServer testLLUDPServer; 204 TestLLUDPServer testLLUDPServer;
187 TestLLPacketServer testLLPacketServer; 205 TestLLPacketServer testLLPacketServer;
@@ -241,21 +259,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
241 [Test] 259 [Test]
242 public void TestExceptionOnBeginReceive() 260 public void TestExceptionOnBeginReceive()
243 { 261 {
244 /*
245 MockScene scene = new MockScene(); 262 MockScene scene = new MockScene();
246 263
247 uint circuitCodeA = 130000; 264 uint circuitCodeA = 130000;
248 EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300); 265 EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300);
266 UUID agentIdA = UUID.Parse("00000000-0000-0000-0000-000000001300");
267 UUID sessionIdA = UUID.Parse("00000000-0000-0000-0000-000000002300");
268
249 uint circuitCodeB = 130001; 269 uint circuitCodeB = 130001;
250 EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301); 270 EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301);
271 UUID agentIdB = UUID.Parse("00000000-0000-0000-0000-000000001301");
272 UUID sessionIdB = UUID.Parse("00000000-0000-0000-0000-000000002301");
251 273
252 TestLLUDPServer testLLUDPServer; 274 TestLLUDPServer testLLUDPServer;
253 TestLLPacketServer testLLPacketServer; 275 TestLLPacketServer testLLPacketServer;
254 AgentCircuitManager acm; 276 AgentCircuitManager acm;
255 SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); 277 SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
256 AddClient(circuitCodeA, epA, testLLUDPServer, acm); 278 AddClient(circuitCodeA, epA, agentIdA, sessionIdA, testLLUDPServer, acm);
257 AddClient(circuitCodeB, epB, testLLUDPServer, acm); 279 AddClient(circuitCodeB, epB, agentIdB, sessionIdB, testLLUDPServer, acm);
258 */ 280
281 testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet1"), epA);
282 testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet2"), epB);
283 testLLUDPServer.LoadReceiveWithBeginException(epA);
284 testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(2, "packet3"), epB);
285 testLLUDPServer.ReceiveData(null);
286
287 Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(3));
288 Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(3));
259 } 289 }
260 } 290 }
261} 291} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
index 002b493..67b8f42 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
@@ -52,7 +52,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
52 { 52 {
53 ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); 53 ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
54 reusedEpSender = tuple.Sender; 54 reusedEpSender = tuple.Sender;
55 throw new SocketException(); 55 ResetServerEndPoint(new SocketException());
56 ReceiveData(null);
56 } 57 }
57 } 58 }
58 59
@@ -60,13 +61,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
60 { 61 {
61 numBytes = 0; 62 numBytes = 0;
62 63
64 //System.Console.WriteLine("Queue size " + m_chunksToLoad.Count);
65
63 if (m_chunksToLoad.Count <= 0) 66 if (m_chunksToLoad.Count <= 0)
64 return false; 67 return false;
65 68
66 ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); 69 ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
67 RecvBuffer = tuple.Data; 70 RecvBuffer = tuple.Data;
68 numBytes = tuple.Data.Length; 71 numBytes = tuple.Data.Length;
69 epSender = tuple.Sender; 72 epSender = tuple.Sender;
70 73
71 return true; 74 return true;
72 } 75 }