Skip to content

Commit 4471630

Browse files
committed
Fixing 100% CPU untilisation when SSL negotiations fail
Fix for TooTallNate#458 (code cleanup of TooTallNate#459)
1 parent 7f9f9df commit 4471630

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
@@ -162,6 +162,14 @@ private synchronized ByteBuffer wrap( ByteBuffer b ) throws SSLException {
162162
**/
163163
private synchronized ByteBuffer unwrap() throws SSLException {
164164
int rem;
165+
//There are some ssl test suites, which get around the selector.select() call, which cause an infinite unwrap and 100% cpu usage (see #459 and #458)
166+
if(readEngineResult.getStatus() == SSLEngineResult.Status.CLOSED && sslEngine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING){
167+
try {
168+
close();
169+
} catch (IOException e) {
170+
//Not really interesting
171+
}
172+
}
165173
do {
166174
rem = inData.remaining();
167175
readEngineResult = sslEngine.unwrap( inCrypt, inData );

0 commit comments

Comments
 (0)