Author: fhanik Date: Fri Jul 7 07:28:08 2006 New Revision: 419896 URL: http://svn.apache.org/viewvc?rev=419896&view=rev Log: Minor adjustments
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/AbstractSender.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReceiver.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/AbstractSender.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/AbstractSender.java?rev=419896&r1=419895&r2=419896&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/AbstractSender.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/AbstractSender.java Fri Jul 7 07:28:08 2006 @@ -113,11 +113,10 @@ */ public boolean keepalive() { boolean disconnect = false; - if ( keepAliveCount >= 0 && requestCount>keepAliveCount ) disconnect = true; - else if ( keepAliveTime >= 0 && keepAliveTime> (System.currentTimeMillis()-connectTime) ) disconnect = true; - if ( disconnect ) disconnect(); - return disconnect; - + if ( keepAliveCount >= 0 && requestCount>keepAliveCount ) disconnect = true; + else if ( keepAliveTime >= 0 && keepAliveTime> (System.currentTimeMillis()-connectTime) ) disconnect = true; + if ( disconnect ) disconnect(); + return disconnect; } protected void setConnected(boolean connected){ Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReceiver.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReceiver.java?rev=419896&r1=419895&r2=419896&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReceiver.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReceiver.java Fri Jul 7 07:28:08 2006 @@ -160,14 +160,16 @@ } public static void cancelledKey(SelectionKey key) { - try { - key.cancel(); - key.channel().close(); - key.attach(null); - } catch (IOException e) { - if (log.isDebugEnabled()) log.debug("", e); - // Ignore + ObjectReader reader = (ObjectReader)key.attachment(); + if ( reader != null ) { + reader.setCancelled(true); + reader.finish(); } + key.cancel(); + key.attach(null); + try { ((SocketChannel)key.channel()).socket().close(); } catch (IOException e) { if (log.isDebugEnabled()) log.debug("", e); } + try { key.channel().close(); } catch (IOException e) { if (log.isDebugEnabled()) log.debug("", e); } + } protected void socketTimeouts() { @@ -193,6 +195,9 @@ long delta = now - ka.getLastAccess(); if (delta > (long) getTimeout() && (!ka.isAccessed())) { log.warn("Channel key is registered, but has had no interest ops for the last "+getTimeout()+" ms. (cancelled:"+ka.isCancelled()+")"); +// System.out.println("Interest:"+key.interestOps()); +// System.out.println("Ready Ops:"+key.readyOps()); +// System.out.println("Valid:"+key.isValid()); ka.setLastAccess(now); //key.interestOps(SelectionKey.OP_READ); }//end if Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java?rev=419896&r1=419895&r2=419896&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java Fri Jul 7 07:28:08 2006 @@ -77,11 +77,13 @@ if (key == null) { continue; // just in case } - ObjectReader reader = (ObjectReader)key.attachment(); try { - reader.setLastAccess(System.currentTimeMillis()); - reader.access(); - drainChannel (key,reader); + ObjectReader reader = (ObjectReader)key.attachment(); + if ( reader == null ) { + cancelKey(key); + } else { + drainChannel(key, reader); + } } catch (Exception e) { //this is common, since the sockets on the other //end expire after a certain time. @@ -97,7 +99,7 @@ } cancelKey(key); } finally { - reader.finish(); + } key = null; // done, ready for more, return to pool @@ -132,6 +134,8 @@ * so the selector will resume watching this channel. */ protected void drainChannel (final SelectionKey key, ObjectReader reader) throws Exception { + reader.setLastAccess(System.currentTimeMillis()); + reader.access(); SocketChannel channel = (SocketChannel) key.channel(); int count; buffer.clear(); // make buffer empty @@ -158,7 +162,7 @@ ChannelMessage[] msgs = pkgcnt == 0? ChannelData.EMPTY_DATA_ARRAY : reader.execute(); - registerForRead(key);//register to read new data, before we send it off to avoid dead locks + registerForRead(key,reader);//register to read new data, before we send it off to avoid dead locks for ( int i=0; i<msgs.length; i++ ) { /** @@ -203,7 +207,8 @@ cancelKey(key); } - protected void registerForRead(final SelectionKey key) { + protected void registerForRead(final SelectionKey key, ObjectReader reader) { + reader.finish(); //register our OP_READ interest Runnable r = new Runnable() { public void run() { Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java?rev=419896&r1=419895&r2=419896&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java Fri Jul 7 07:28:08 2006 @@ -47,6 +47,7 @@ ParallelNioSender sender = (ParallelNioSender)getSender(); try { sender.sendMessage(destination, message); + sender.keepalive(); }finally { if ( !connected ) disconnect(); returnSender(sender); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]