aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs103
-rw-r--r--OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs7
2 files changed, 53 insertions, 57 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 40b4a42..52a2467 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -271,17 +271,59 @@ namespace OpenSim.Region.ClientStack.LindenUDP
271 m_socket.BeginReceiveFrom( 271 m_socket.BeginReceiveFrom(
272 RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); 272 RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null);
273 } 273 }
274 catch (SocketException) 274 catch (SocketException e)
275 { 275 {
276 // We don't need to see this error, reset connection and get next UDP packet off the buffer
277 // If the UDP packet is part of the same stream, this will happen several hundreds of times before
278 // the next set of UDP data is for a valid client.
279 //m_log.ErrorFormat("[CLIENT]: BeginRecieve threw exception " + e.Message + ": " + e.StackTrace );
280
281 // ENDLESS LOOP ON PURPOSE! 276 // ENDLESS LOOP ON PURPOSE!
282 ResetEndPoint(); 277 // Reset connection and get next UDP packet off the buffer
278 // If the UDP packet is part of the same stream, this will happen several hundreds of times before
279 // the next set of UDP data is for a valid client.
280 ResetServerEndPoint(e);
283 } 281 }
284 } 282 }
283
284 /// <summary>
285 /// Reset the server endpoint
286 /// </summary>
287 /// <param name="e">
288 /// The exception that has triggered the reset. Can be null if there was no exception.
289 /// </param>
290 private void ResetServerEndPoint(Exception e)
291 {
292 try
293 {
294 CloseCircuit(reusedEpSender, e);
295 }
296 catch (Exception a)
297 {
298 m_log.Error("[UDPSERVER]: " + a);
299 }
300
301 // ENDLESS LOOP ON PURPOSE!
302 // We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die
303 // The only way to do that is to beginreceive again!
304 BeginReceive();
305 }
306
307 /// <summary>
308 /// Close a client circuit. This is done in response to an exception on receive, and should not be called
309 /// normally.
310 /// </summary>
311 /// <param name="sender"></param>
312 /// <param name="e">The exception that caused the close. Can be null if there was no exception</param>
313 private void CloseCircuit(EndPoint sender, Exception e)
314 {
315 uint circuit;
316 lock (clientCircuits)
317 {
318 if (clientCircuits.TryGetValue(sender, out circuit))
319 {
320 m_packetServer.CloseCircuit(circuit);
321
322 if (e != null)
323 m_log.ErrorFormat("[CLIENT]: Closed circuit {0} {1} due to exception {2}", circuit, sender, e);
324 }
325 }
326 }
285 327
286 /// <summary> 328 /// <summary>
287 /// Finish the process of asynchronously receiving the next bit of raw data 329 /// Finish the process of asynchronously receiving the next bit of raw data
@@ -327,53 +369,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
327 return hasReceivedOkay; 369 return hasReceivedOkay;
328 } 370 }
329 371
330 private void ResetEndPoint()
331 {
332 try
333 {
334 CloseEndPoint(reusedEpSender);
335 }
336 catch (Exception a)
337 {
338 m_log.Error("[UDPSERVER]: " + a);
339 }
340
341 // ENDLESS LOOP ON PURPOSE!
342
343 // We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die
344 // The only way to do that is to beginreceive again!
345 BeginReceive();
346
347 try
348 {
349 // m_socket.BeginReceiveFrom(
350 // RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null);
351
352 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
353 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
354 // This will happen over and over until we've gone through all packets
355 // sent to and from this particular user.
356 // Stupid I know..
357 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
358 }
359 catch (SocketException e)
360 {
361 m_log.DebugFormat("[UDPSERVER]: Exception {0} : {1}", e.Message, e.StackTrace );
362 }
363 }
364
365 private void CloseEndPoint(EndPoint sender)
366 {
367 uint circuit;
368 lock (clientCircuits)
369 {
370 if (clientCircuits.TryGetValue(sender, out circuit))
371 {
372 m_packetServer.CloseCircuit(circuit);
373 }
374 }
375 }
376
377 /// <summary> 372 /// <summary>
378 /// Add a new client circuit. 373 /// Add a new client circuit.
379 /// </summary> 374 /// </summary>
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs
index 94dfd75..0ec4a8b 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs
@@ -40,11 +40,12 @@ namespace OpenSim.Region.Environment.Scenes.Tests
40 [TestFixture] 40 [TestFixture]
41 public class SceneTests 41 public class SceneTests
42 { 42 {
43 /// <summary>
44 /// Test adding an object to a scene. Doesn't yet do what it says on the tin.
45 /// </summary>
43 [Test] 46 [Test]
44 public void TestAddSceneObject() 47 public void TestAddSceneObject()
45 { 48 {
46 //System.Console.WriteLine("Hello mum!");
47
48 RegionInfo regInfo = new RegionInfo(1000, 1000, null, null); 49 RegionInfo regInfo = new RegionInfo(1000, 1000, null, null);
49 regInfo.RegionName = "Unit test region"; 50 regInfo.RegionName = "Unit test region";
50 AgentCircuitManager acm = new AgentCircuitManager(); 51 AgentCircuitManager acm = new AgentCircuitManager();