Browse Source

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

PSp..om 14 years ago
parent
commit
d0a5ce55b9

+ 18 - 6
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() );                    
+                }                        
             }
         }