You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2014/03/10 22:42:40 UTC

svn commit: r1576097 - /tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java

Author: remm
Date: Mon Mar 10 21:42:40 2014
New Revision: 1576097

URL: http://svn.apache.org/r1576097
Log:
- Closing is not an async operation, but needs to be performed, so ignore errors if some pending things are going on with SSL.
- Also fix some warnings.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1576097&r1=1576096&r2=1576097&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Mon Mar 10 21:42:40 2014
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.AsynchronousSocketChannel;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.CompletionHandler;
+import java.nio.channels.WritePendingException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -332,7 +333,6 @@ public class SecureNio2Channel extends N
 
     /**
      * Performs the WRAP function
-     * @param doWrite boolean
      * @return SSLEngineResult
      * @throws IOException
      */
@@ -351,7 +351,6 @@ public class SecureNio2Channel extends N
 
     /**
      * Perform handshake unwrap
-     * @param doread boolean
      * @return SSLEngineResult
      * @throws IOException
      */
@@ -408,6 +407,8 @@ public class SecureNio2Channel extends N
             }
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             throw new IOException("Remaining data in the network buffer, can't send SSL close message, force a close with close(true) instead", e);
+        } catch (WritePendingException e) {
+            // Ingore
         }
         //prep the buffer for the close message
         netOutBuffer.clear();
@@ -420,7 +421,15 @@ public class SecureNio2Channel extends N
         //prepare the buffer for writing
         netOutBuffer.flip();
         //if there is data to be written
-        flush();
+        try {
+            if (!flush().get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS).booleanValue()) {
+                throw new IOException("Remaining data in the network buffer, can't send SSL close message, force a close with close(true) instead");
+            }
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
+            throw new IOException("Remaining data in the network buffer, can't send SSL close message, force a close with close(true) instead", e);
+        } catch (WritePendingException e) {
+            // Ingore
+        }
 
         //is the channel closed?
         closed = (!netOutBuffer.hasRemaining() && (handshake.getHandshakeStatus() != HandshakeStatus.NEED_WRAP));



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