From: markt Date: Sun, 27 Feb 2011 11:28:01 +0000 (+0000) Subject: Block whilst waiting for data from client in NIO SSL-rehandshake rather than spinning... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=37edc05cce7373a206486451cc415ea07ad4451e;p=tomcat7.0 Block whilst waiting for data from client in NIO SSL-rehandshake rather than spinning the CPU git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1075030 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/SecureNioChannel.java b/java/org/apache/tomcat/util/net/SecureNioChannel.java index 04dc5ac97..35a7f15a9 100644 --- a/java/org/apache/tomcat/util/net/SecureNioChannel.java +++ b/java/org/apache/tomcat/util/net/SecureNioChannel.java @@ -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 {