Skip to content

Commit

Permalink
Revert "[fix] jruby hang with TLS due not executing task"
Browse files Browse the repository at this point in the history
This reverts commit d1731a5.
  • Loading branch information
kares committed May 31, 2022
1 parent d1731a5 commit 3c5727f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ext/puma_http11/org/jruby/puma/MiniSSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ private SSLEngineResult doOp(SSLOperation sslOp, MiniSSLBuffer src, MiniSSLBuffe
}
}

// after each op, run any delegated tasks if needed
if(res.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
Runnable runnable;
while ((runnable = engine.getDelegatedTask()) != null) {
runnable.run();
}
}

return res;
}

Expand All @@ -372,31 +380,25 @@ public IRubyObject read() {

HandshakeStatus handshakeStatus = engine.getHandshakeStatus();
boolean done = false;
SSLEngineResult res = null;
while (!done) {
SSLEngineResult res;
switch (handshakeStatus) {
case NEED_WRAP:
res = doOp(SSLOperation.WRAP, inboundAppData, outboundNetData);
handshakeStatus = res.getHandshakeStatus();
break;
case NEED_UNWRAP:
res = doOp(SSLOperation.UNWRAP, inboundNetData, inboundAppData);
if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
// need more data before we can shake more hands
done = true;
}
handshakeStatus = res.getHandshakeStatus();
break;
case NEED_TASK:
Runnable runnable;
while ((runnable = engine.getDelegatedTask()) != null) {
runnable.run();
}
handshakeStatus = engine.getHandshakeStatus();
break;
default:
done = true;
}
if (!done) {
handshakeStatus = res.getHandshakeStatus();
}
}

if (inboundNetData.hasRemaining()) {
Expand Down

0 comments on commit 3c5727f

Please sign in to comment.