activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1057260 - /activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java
Date Mon, 10 Jan 2011 16:25:08 GMT
Author: chirino
Date: Mon Jan 10 16:25:08 2011
New Revision: 1057260

URL: http://svn.apache.org/viewvc?rev=1057260&view=rev
Log:
Fixes tight spin loop that can occur.

Modified:
    activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java

Modified: activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java?rev=1057260&r1=1057259&r2=1057260&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-tcp/src/main/java/org/apache/activemq/apollo/transport/tcp/SslTransport.java
Mon Jan 10 16:25:08 2011
@@ -186,15 +186,19 @@ public class SslTransport extends TcpTra
         int rc=0;
         while ( plain.hasRemaining() || engine.getHandshakeStatus() == NEED_UNWRAP ) {
             if( readOverflowBuffer !=null ) {
-                // lets drain the overflow buffer before trying to suck down anymore
-                // network bytes.
-                int size = Math.min(plain.remaining(), readOverflowBuffer.remaining());
-                plain.put(readOverflowBuffer.array(), readOverflowBuffer.position(), size);
-                readOverflowBuffer.position(readOverflowBuffer.position()+size);
-                if( !readOverflowBuffer.hasRemaining() ) {
-                    readOverflowBuffer = null;
+                if(  plain.hasRemaining() ) {
+                    // lets drain the overflow buffer before trying to suck down anymore
+                    // network bytes.
+                    int size = Math.min(plain.remaining(), readOverflowBuffer.remaining());
+                    plain.put(readOverflowBuffer.array(), readOverflowBuffer.position(),
size);
+                    readOverflowBuffer.position(readOverflowBuffer.position()+size);
+                    if( !readOverflowBuffer.hasRemaining() ) {
+                        readOverflowBuffer = null;
+                    }
+                    rc += size;
+                } else {
+                    return rc;
                 }
-                rc += size;
             } else if( readUnderflow ) {
                 int count = channel.read(readBuffer);
                 if( count == -1 ) {  // peer closed socket.



Mime
View raw message