Author: fhanik Date: Mon Oct 30 09:47:26 2006 New Revision: 469207 URL: http://svn.apache.org/viewvc?view=rev&rev=469207 Log: Fixed null pointer exception on comet socket timeout
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?view=diff&rev=469207&r1=469206&r2=469207 ============================================================================== --- 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 Mon Oct 30 09:47:26 2006 @@ -1138,13 +1138,14 @@ public void cancelledKey(SelectionKey key, SocketStatus status) { try { KeyAttachment ka = (KeyAttachment) key.attachment(); - if ( key.isValid() ) key.cancel(); - if (ka != null && ka.getComet()) processSocket( ka.getChannel(), status); - // FIXME: closing in all these cases is a bit mean. IMO, it should leave it - // to the worker (or executor) depending on what the request processor - // returns - if ( key.channel().isOpen() ) key.channel().close(); - key.attach(null); + if (ka != null && ka.getComet()) { + //the comet event takes care of clean up + processSocket(ka.getChannel(), status); + }else { + if (key.isValid()) key.cancel(); + if (key.channel().isOpen()) key.channel().close(); + key.attach(null); + } } catch (Throwable e) { if ( log.isDebugEnabled() ) log.error("",e); // Ignore @@ -1257,6 +1258,8 @@ long timeout = (ka.getTimeout()==-1)?((long) socketProperties.getSoTimeout()):(ka.getTimeout()); boolean isTimedout = delta > timeout; if (isTimedout) { + key.interestOps(0); + ka.interestOps(0); //avoid duplicate timeout calls cancelledKey(key, SocketStatus.TIMEOUT); } else { long nextTime = now+(timeout-delta); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]