Skip to content

Commit b4fb6b3

Browse files
committed
SSLSocketChannel2: throttle processHandshake() if no handshake is done
Signed-off-by: Juhyung Park <[email protected]>
1 parent 8c5766a commit b4fb6b3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/java_websocket/SSLSocketChannel2.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ private synchronized void processHandshake(boolean isReading) throws IOException
190190
if (writeEngineResult.getHandshakeStatus() == HandshakeStatus.FINISHED) {
191191
createBuffers(sslEngine.getSession());
192192
return;
193+
} else {
194+
// processHandshake() can spin in a loop if a connection is made with no SSL handshake,
195+
// throttle this by delaying 10ms to avoid consuming a CPU core.
196+
try {
197+
Thread.sleep(10);
198+
} catch (InterruptedException e) {
199+
// Ignore
200+
}
193201
}
194202
}
195203
assert (sslEngine.getHandshakeStatus()

0 commit comments

Comments
 (0)