From 37edc05cce7373a206486451cc415ea07ad4451e Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 27 Feb 2011 11:28:01 +0000 Subject: [PATCH] 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 --- java/org/apache/tomcat/util/net/SecureNioChannel.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 { -- 2.11.0