aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP
diff options
context:
space:
mode:
authorlbsa712009-03-25 19:30:36 +0000
committerlbsa712009-03-25 19:30:36 +0000
commit3cb06cc4ccb521e98ba43a223dd896e019b3b9b6 (patch)
tree8df1c3e0d7d35e2e0ca790a14e684268e20308e6 /OpenSim/Region/ClientStack/LindenUDP
parent* minor: Adjust exception catching on load/save xml[2]/oar. (diff)
downloadopensim-SC_OLD-3cb06cc4ccb521e98ba43a223dd896e019b3b9b6.zip
opensim-SC_OLD-3cb06cc4ccb521e98ba43a223dd896e019b3b9b6.tar.gz
opensim-SC_OLD-3cb06cc4ccb521e98ba43a223dd896e019b3b9b6.tar.bz2
opensim-SC_OLD-3cb06cc4ccb521e98ba43a223dd896e019b3b9b6.tar.xz
* Changed a recursive BeginRobustReceive loop to a flat while loop to avoid lethal stack overflows.
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs71
1 files changed, 33 insertions, 38 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index e29ec4e..3b9d293 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -291,47 +291,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP
291 /// </summary> 291 /// </summary>
292 private void BeginRobustReceive() 292 private void BeginRobustReceive()
293 { 293 {
294 try 294 bool done = false;
295 {
296 BeginReceive();
297 }
298 catch (SocketException e)
299 {
300 // ENDLESS LOOP ON PURPOSE!
301 // Reset connection and get next UDP packet off the buffer
302 // If the UDP packet is part of the same stream, this will happen several hundreds of times before
303 // the next set of UDP data is for a valid client.
304 ResetServerEndPoint(e);
305 }
306 catch (ObjectDisposedException)
307 {
308 m_log.Info("[UDPSERVER]: UDP Object disposed. No need to worry about this if you're restarting the simulator.");
309 }
310 }
311 295
312 /// <summary> 296 while (!done)
313 /// Reset the server endpoint
314 /// </summary>
315 /// <param name="e">
316 /// The exception that has triggered the reset. Can be null if there was no exception.
317 /// </param>
318 private void ResetServerEndPoint(Exception e)
319 {
320 try
321 { 297 {
322 CloseCircuit(e); 298 try
323 } 299 {
324 catch (Exception e2) 300 BeginReceive();
325 { 301 done = true;
326 m_log.ErrorFormat( 302 }
327 "[CLIENT]: Exception thrown when trying to close the circuit for {0} - {1}", reusedEpSender, e2); 303 catch (SocketException e)
328 } 304 {
305 // ENDLESS LOOP ON PURPOSE!
306 // Reset connection and get next UDP packet off the buffer
307 // If the UDP packet is part of the same stream, this will happen several hundreds of times before
308 // the next set of UDP data is for a valid client.
329 309
330 // ENDLESS LOOP ON PURPOSE! 310 try
331 // We need to purge the UDP stream of crap from the client that disconnected nastily or the UDP server will die 311 {
332 // The only way to do that is to BeginRobustReceive again! 312 CloseCircuit(e);
333 BeginRobustReceive(); 313 }
334 } 314 catch (Exception e2)
315 {
316 m_log.ErrorFormat(
317 "[CLIENT]: Exception thrown when trying to close the circuit for {0} - {1}", reusedEpSender,
318 e2);
319 }
320 }
321 catch (ObjectDisposedException)
322 {
323 m_log.Info(
324 "[UDPSERVER]: UDP Object disposed. No need to worry about this if you're restarting the simulator.");
325
326 done = true;
327 }
328 }
329 }
335 330
336 /// <summary> 331 /// <summary>
337 /// Close a client circuit. This is done in response to an exception on receive, and should not be called 332 /// Close a client circuit. This is done in response to an exception on receive, and should not be called