Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 91555 invoked from network); 1 Jul 2006 23:16:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Jul 2006 23:16:34 -0000 Received: (qmail 11455 invoked by uid 500); 1 Jul 2006 23:16:27 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 11398 invoked by uid 500); 1 Jul 2006 23:16:26 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 11387 invoked by uid 500); 1 Jul 2006 23:16:26 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 11382 invoked by uid 99); 1 Jul 2006 23:16:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jul 2006 16:16:26 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jul 2006 16:16:25 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C13861A983A; Sat, 1 Jul 2006 16:16:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r418517 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport: ThreadPool.java bio/BioReplicationThread.java nio/NioReplicationThread.java Date: Sat, 01 Jul 2006 23:16:05 -0000 To: tomcat-dev@jakarta.apache.org From: fhanik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060701231605.C13861A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: fhanik Date: Sat Jul 1 16:16:04 2006 New Revision: 418517 URL: http://svn.apache.org/viewvc?rev=418517&view=rev Log: Fixed threading hand off, now works correctly Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ThreadPool.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ThreadPool.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ThreadPool.java?rev=418517&r1=418516&r2=418517&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ThreadPool.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ThreadPool.java Sat Jul 1 16:16:04 2006 @@ -62,11 +62,14 @@ } protected void setupThread(WorkerThread thread) { - thread.setPool(this); - thread.setName (thread.getClass().getName()+"[" + inc()+"]"); - thread.setDaemon(true); - thread.setPriority(Thread.MAX_PRIORITY); - thread.start(); + synchronized (thread) { + thread.setPool(this); + thread.setName(thread.getClass().getName() + "[" + inc() + "]"); + thread.setDaemon(true); + thread.setPriority(Thread.MAX_PRIORITY); + thread.start(); + try {thread.wait(500); }catch ( InterruptedException x ) {} + } } /** Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java?rev=418517&r1=418516&r2=418517&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java Sat Jul 1 16:16:04 2006 @@ -58,6 +58,7 @@ // loop forever waiting for work to do public synchronized void run() { + this.notify(); while (isDoRun()) { try { // sleep and release object lock 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=418517&r1=418516&r2=418517&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 Sat Jul 1 16:16:04 2006 @@ -59,6 +59,7 @@ // loop forever waiting for work to do public synchronized void run() { + this.notify(); if ( (getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER ) { buffer = ByteBuffer.allocateDirect(getRxBufSize()); }else { @@ -77,8 +78,11 @@ if (key == null) { continue; // just in case } + ObjectReader reader = (ObjectReader)key.attachment(); try { - drainChannel (key); + reader.setLastAccess(System.currentTimeMillis()); + reader.access(); + drainChannel (key,reader); } catch (Exception e) { //this is common, since the sockets on the other //end expire after a certain time. @@ -86,13 +90,15 @@ //do nothing } else if ( e instanceof IOException ) { //dont spew out stack traces for IO exceptions unless debug is enabled. - if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed.", e); - else log.warn ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed."); + if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].", e); + else log.warn ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"]."); } else if ( log.isErrorEnabled() ) { //this is a real error, log it. log.error("Exception caught in TcpReplicationThread.drainChannel.",e); } cancelKey(key); + } finally { + reader.finish(); } key = null; // done, ready for more, return to pool @@ -126,59 +132,51 @@ * re-enables OP_READ and calls wakeup() on the selector * so the selector will resume watching this channel. */ - protected void drainChannel (final SelectionKey key) throws Exception { + protected void drainChannel (final SelectionKey key, ObjectReader reader) throws Exception { SocketChannel channel = (SocketChannel) key.channel(); int count; buffer.clear(); // make buffer empty - ObjectReader reader = (ObjectReader)key.attachment(); - reader.setLastAccess(System.currentTimeMillis()); - try { - reader.access(); - // loop while data available, channel is non-blocking - while ((count = channel.read (buffer)) > 0) { - buffer.flip(); // make buffer readable - if ( buffer.hasArray() ) - reader.append(buffer.array(),0,count,false); - else - reader.append(buffer,count,false); - buffer.clear(); // make buffer empty - } + // loop while data available, channel is non-blocking + while ((count = channel.read (buffer)) > 0) { + buffer.flip(); // make buffer readable + if ( buffer.hasArray() ) + reader.append(buffer.array(),0,count,false); + else + reader.append(buffer,count,false); + buffer.clear(); // make buffer empty + } - int pkgcnt = reader.count(); + int pkgcnt = reader.count(); - if ( pkgcnt > 0 ) { - ChannelMessage[] msgs = reader.execute(); - for ( int i=0; i 0 ) { + ChannelMessage[] msgs = reader.execute(); + for ( int i=0; i