Block whilst waiting for data from client in NIO SSL-rehandshake rather than spinning...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 27 Feb 2011 11:28:01 +0000 (11:28 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 27 Feb 2011 11:28:01 +0000 (11:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1075030 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/SecureNioChannel.java

index 04dc5ac..35a7f15 100644 (file)
@@ -294,7 +294,18 @@ public class SecureNioChannel extends NioChannel  {
             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 {