Author: fhanik Date: Thu Jun 22 12:59:39 2006 New Revision: 416456 URL: http://svn.apache.org/viewvc?rev=416456&view=rev Log: Catch the cancelled key exceptions and act appropriately
Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=416456&r1=416455&r2=416456&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java Thu Jun 22 12:59:39 2006 @@ -32,6 +32,7 @@ import java.nio.channels.SelectionKey; import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; import org.apache.tomcat.util.net.NioEndpoint.Poller; +import java.nio.channels.CancelledKeyException; /** * Implementation of InputBuffer which provides HTTP request header parsing as @@ -564,13 +565,21 @@ if ( !timedOut && nRead == 0 ) try { final SelectionKey key = socket.keyFor(poller.getSelector()); - KeyAttachment att = (KeyAttachment)key.attachment(); + final KeyAttachment att = (KeyAttachment)key.attachment(); att.setWakeUp(true); poller.addEvent( new Runnable() { public void run() { - if ( key != null ) key.interestOps(SelectionKey.OP_READ); + try { + if (key != null) key.interestOps(SelectionKey.OP_READ); + } catch (CancelledKeyException ckx) { + try { + socket.socket().close(); + socket.close(); + att.setWakeUp(false); + } catch (Exception ignore) {} + } } }); synchronized (att.getMutex()) { att.getMutex().wait(25);} Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=416456&r1=416455&r2=416456&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Thu Jun 22 12:59:39 2006 @@ -1106,7 +1106,14 @@ if ( att != null ) att.setWakeUp(false); Runnable r = new Runnable() { public void run() { - if ( key != null ) key.interestOps(SelectionKey.OP_READ); + try { + if (key != null) key.interestOps(SelectionKey.OP_READ); + }catch ( CancelledKeyException ckx ) { + try { + socket.socket().close(); + socket.close(); + } catch ( Exception ignore ) {} + } } }; addEvent(r); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]