Skip to content

Commit 3816d68

Browse files
authored
Merge pull request TooTallNate#461 from marci4/master
Fixing 100% CPU untilisation when SSL negotiations fail
2 parents 7f9f9df + 4471630 commit 3816d68

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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)