From d0a5ce55b94c1804f49c1f6189399dd7e3bb7422 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Mon, 18 Apr 2011 17:27:11 +0000 Subject: [PATCH] Moved some exception handling to terminate connections that throw low level exceptions. The specific case I saw for this was "An existing connection was forcibly closed by the remote host" IOException. Without this new handling, SM continually tried to send the connection its data. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7260 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../network/kernel/tcp/SelectorKernel.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/engine/src/networking/com/jme3/network/kernel/tcp/SelectorKernel.java b/engine/src/networking/com/jme3/network/kernel/tcp/SelectorKernel.java index 392f9b243..659591764 100644 --- a/engine/src/networking/com/jme3/network/kernel/tcp/SelectorKernel.java +++ b/engine/src/networking/com/jme3/network/kernel/tcp/SelectorKernel.java @@ -418,12 +418,24 @@ public class SelectorKernel extends AbstractKernel continue; } - if( key.isAcceptable() ) - accept(key); - else if( key.isWritable() ) - write(key); - else if( key.isReadable() ) - read(key); + try { + if( key.isAcceptable() ) + accept(key); + else if( key.isWritable() ) + write(key); + else if( key.isReadable() ) + read(key); + } catch( IOException e ) { + if( !go.get() ) + return; // error likely due to shutting down + reportError( e ); + + // And at this level, errors likely mean the key is now + // dead and it doesn't hurt to kick them anyway. If we + // find IOExceptions that are not fatal, this can be + // readdressed + cancel( key, (SocketChannel)key.channel() ); + } } }