Author: markt
Date: Sun Feb 27 11:28:01 2011
New Revision: 1075030

URL: http://svn.apache.org/viewvc?rev=1075030&view=rev
Log:
Block whilst waiting for data from client in NIO SSL-rehandshake rather than 
spinning the CPU

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

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java?rev=1075030&r1=1075029&r2=1075030&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java Sun Feb 
27 11:28:01 2011
@@ -294,7 +294,18 @@ public class SecureNioChannel extends Ni
             while (!handshakeComplete) {
                 handshake(true, true);
                 if (handshakeStatus == HandshakeStatus.NEED_UNWRAP)  {
-                    handshakeUnwrap(true);
+                    // Block until there is data to read from the client
+                    Selector selector = null;
+                    try {
+                        selector = Selector.open();
+                        sc.register(selector, SelectionKey.OP_READ);
+                        selector.select();
+                        handshakeUnwrap(true);
+                    } finally {
+                        if (selector != null) {
+                            selector.close();
+                        }
+                    }
                 }
             }
         } finally {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to