Merge changes back from 3.2 branch which fixes a deadlock in the
SslHandler. See NETTY-443
This commit is contained in:
parent
2ae095f92c
commit
a67e550207
@ -871,42 +871,50 @@ public class SslHandler extends FrameDecoder
|
|||||||
loop:
|
loop:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SSLEngineResult result;
|
SSLEngineResult result;
|
||||||
|
boolean needsHandshake = false;
|
||||||
synchronized (handshakeLock) {
|
synchronized (handshakeLock) {
|
||||||
if (!handshaken && !handshaking &&
|
if (!handshaken && !handshaking &&
|
||||||
!engine.getUseClientMode() &&
|
!engine.getUseClientMode() &&
|
||||||
!engine.isInboundDone() && !engine.isOutboundDone()) {
|
!engine.isInboundDone() && !engine.isOutboundDone()) {
|
||||||
handshake();
|
needsHandshake = true;
|
||||||
}
|
|
||||||
|
|
||||||
result = engine.unwrap(inNetBuf, outAppBuf);
|
|
||||||
|
|
||||||
final HandshakeStatus handshakeStatus = result.getHandshakeStatus();
|
|
||||||
handleRenegotiation(handshakeStatus);
|
|
||||||
switch (handshakeStatus) {
|
|
||||||
case NEED_UNWRAP:
|
|
||||||
if (inNetBuf.hasRemaining() && !engine.isInboundDone()) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
break loop;
|
|
||||||
}
|
|
||||||
case NEED_WRAP:
|
|
||||||
wrapNonAppData(ctx, channel);
|
|
||||||
break;
|
|
||||||
case NEED_TASK:
|
|
||||||
runDelegatedTasks();
|
|
||||||
break;
|
|
||||||
case FINISHED:
|
|
||||||
setHandshakeSuccess(channel);
|
|
||||||
needsWrap = true;
|
|
||||||
break loop;
|
|
||||||
case NOT_HANDSHAKING:
|
|
||||||
needsWrap = true;
|
|
||||||
break loop;
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Unknown handshake status: " + handshakeStatus);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (needsHandshake) {
|
||||||
|
handshake();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (handshakeLock) {
|
||||||
|
result = engine.unwrap(inNetBuf, outAppBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
final HandshakeStatus handshakeStatus = result.getHandshakeStatus();
|
||||||
|
handleRenegotiation(handshakeStatus);
|
||||||
|
switch (handshakeStatus) {
|
||||||
|
case NEED_UNWRAP:
|
||||||
|
if (inNetBuf.hasRemaining() && !engine.isInboundDone()) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break loop;
|
||||||
|
}
|
||||||
|
case NEED_WRAP:
|
||||||
|
wrapNonAppData(ctx, channel);
|
||||||
|
break;
|
||||||
|
case NEED_TASK:
|
||||||
|
runDelegatedTasks();
|
||||||
|
break;
|
||||||
|
case FINISHED:
|
||||||
|
setHandshakeSuccess(channel);
|
||||||
|
needsWrap = true;
|
||||||
|
break loop;
|
||||||
|
case NOT_HANDSHAKING:
|
||||||
|
needsWrap = true;
|
||||||
|
break loop;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Unknown handshake status: " + handshakeStatus);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsWrap) {
|
if (needsWrap) {
|
||||||
|
Loading…
Reference in New Issue
Block a user