You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/07/21 21:30:32 UTC
svn commit: r424429 -
/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Author: fhanik
Date: Fri Jul 21 12:30:31 2006
New Revision: 424429
URL: http://svn.apache.org/viewvc?rev=424429&view=rev
Log:
Make sure the key is valid before processing it
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
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=424429&r1=424428&r2=424429&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 Fri Jul 21 12:30:31 2006
@@ -1133,29 +1133,31 @@
iterator.remove();
KeyAttachment attachment = (KeyAttachment)sk.attachment();
try {
- if(attachment == null) attachment = new KeyAttachment();
- attachment.access();
- sk.attach(attachment);
-
- int readyOps = sk.readyOps();
- sk.interestOps(sk.interestOps() & ~readyOps);
- SocketChannel channel = (SocketChannel)sk.channel();
- boolean read = sk.isReadable();
- if (read) {
- if ( attachment.getWakeUp() ) {
- attachment.setWakeUp(false);
- synchronized (attachment.getMutex()) {attachment.getMutex().notifyAll();}
- } else if ( attachment.getComet() ) {
- if (!processSocket(channel,false)) processSocket(channel,true);
- } else {
- boolean close = (!processSocket(channel));
- if ( close ) {
- channel.socket().close();
- channel.close();
+ if ( sk.isValid() ) {
+ if(attachment == null) attachment = new KeyAttachment();
+ attachment.access();
+ sk.attach(attachment);
+ int readyOps = sk.readyOps();
+ sk.interestOps(sk.interestOps() & ~readyOps);
+ SocketChannel channel = (SocketChannel)sk.channel();
+ boolean read = sk.isReadable();
+ if (read) {
+ if ( attachment.getWakeUp() ) {
+ attachment.setWakeUp(false);
+ synchronized (attachment.getMutex()) {attachment.getMutex().notifyAll();}
+ } else if ( attachment.getComet() ) {
+ if (!processSocket(channel,false)) processSocket(channel,true);
+ } else {
+ boolean close = (!processSocket(channel));
+ if ( close ) {
+ channel.socket().close();
+ channel.close();
+ }
}
}
- }
- if (sk.isValid() && sk.isWritable()) {
+ } else {
+ //invalid key
+ cancelledKey(sk);
}
} catch ( CancelledKeyException ckx ) {
if (attachment!=null && attachment.getComet()) processSocket( (SocketChannel) sk.channel(), true);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org