tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r586102 - in /tomcat/sandbox/gdev6x: java/org/apache/tomcat/util/net/SecureNioChannel.java webapps/docs/changelog.xml
Date Thu, 18 Oct 2007 19:41:40 GMT
Author: fhanik
Date: Thu Oct 18 12:41:39 2007
New Revision: 586102

URL: http://svn.apache.org/viewvc?rev=586102&view=rev
Log:
Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=43653

Modified:
    tomcat/sandbox/gdev6x/java/org/apache/tomcat/util/net/SecureNioChannel.java
    tomcat/sandbox/gdev6x/webapps/docs/changelog.xml

Modified: tomcat/sandbox/gdev6x/java/org/apache/tomcat/util/net/SecureNioChannel.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/gdev6x/java/org/apache/tomcat/util/net/SecureNioChannel.java?rev=586102&r1=586101&r2=586102&view=diff
==============================================================================
--- tomcat/sandbox/gdev6x/java/org/apache/tomcat/util/net/SecureNioChannel.java (original)
+++ tomcat/sandbox/gdev6x/java/org/apache/tomcat/util/net/SecureNioChannel.java Thu Oct 18
12:41:39 2007
@@ -393,38 +393,45 @@
      * @todo Implement this java.nio.channels.WritableByteChannel method
      */
     public int write(ByteBuffer src) throws IOException {
-        //make sure we can handle expand, and that we only use on buffer
-        if ( src != bufHandler.getWriteBuffer() ) throw new IllegalArgumentException("You
can only write using the application write buffer provided by the handler.");
-        //are we closing or closed?
-        if ( closing || closed) throw new IOException("Channel is in closing state.");
-        
-        //the number of bytes written
-        int written = 0;
-        
-        if (!flush(netOutBuffer)) {
-            //we haven't emptied out the buffer yet
+        if ( src == this.netOutBuffer ) {
+            //we can get here through a recursive call
+            //by using the NioBlockingSelector
+            int written = sc.write(src);
             return written;
-        }
+        } else {
+            //make sure we can handle expand, and that we only use on buffer
+            if ( src != bufHandler.getWriteBuffer() ) throw new IllegalArgumentException("You
can only write using the application write buffer provided by the handler.");
+            //are we closing or closed?
+            if ( closing || closed) throw new IOException("Channel is in closing state.");
 
-        /*
-         * The data buffer is empty, we can reuse the entire buffer.
-         */
-        netOutBuffer.clear();
-
-        SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
-        written = result.bytesConsumed();
-        netOutBuffer.flip();
+            //the number of bytes written
+            int written = 0;
 
-        if (result.getStatus() == Status.OK) {
-            if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) tasks();
-        } else {
-            throw new IOException("Unable to wrap data, invalid engine state: " +result.getStatus());
-        }        
+            if (!flush(netOutBuffer)) {
+                //we haven't emptied out the buffer yet
+                return written;
+            }
+
+            /*
+             * The data buffer is empty, we can reuse the entire buffer.
+             */
+            netOutBuffer.clear();
 
-        //force a flush
-        flush(netOutBuffer);
+            SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
+            written = result.bytesConsumed();
+            netOutBuffer.flip();
 
-        return written;
+            if (result.getStatus() == Status.OK) {
+                if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) tasks();
+            } else {
+                throw new IOException("Unable to wrap data, invalid engine state: " +result.getStatus());
+            }        
+
+            //force a flush
+            flush(netOutBuffer);
+
+            return written;
+        }
     }
     
     /**

Modified: tomcat/sandbox/gdev6x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/sandbox/gdev6x/webapps/docs/changelog.xml?rev=586102&r1=586101&r2=586102&view=diff
==============================================================================
--- tomcat/sandbox/gdev6x/webapps/docs/changelog.xml (original)
+++ tomcat/sandbox/gdev6x/webapps/docs/changelog.xml Thu Oct 18 12:41:39 2007
@@ -17,6 +17,9 @@
 <body>
 <section name="Tomcat g6.xdev(unknown)">
   <subsection name="Catalina">
+    <fix><bug>43653</bug>
+      Fix for SSL buffer mixup
+    </fix>
     <fix>
       <bug>42925</bug>: Add maintain for sendfile. (remm)
     </fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message