* Reverted previous SslHandler fix that doesn't work

* More strict handshake status check
This commit is contained in:
Trustin Lee 2008-11-16 11:47:35 +00:00
parent ea94ea850b
commit b29b5a8289

View File

@ -473,11 +473,15 @@ public class SslHandler extends FrameDecoder {
break; break;
case FINISHED: case FINISHED:
setHandshakeSuccess(channel); setHandshakeSuccess(channel);
default: case NOT_HANDSHAKING:
if (result.getStatus() == Status.CLOSED) { if (result.getStatus() == Status.CLOSED) {
success = false; success = false;
} }
break loop; break loop;
default:
throw new IllegalStateException(
"Unknown handshake status: " +
result.getHandshakeStatus());
} }
} }
} }
@ -572,10 +576,17 @@ public class SslHandler extends FrameDecoder {
switch (result.getHandshakeStatus()) { switch (result.getHandshakeStatus()) {
case FINISHED: case FINISHED:
setHandshakeSuccess(channel); setHandshakeSuccess(channel);
break;
case NEED_TASK: case NEED_TASK:
runDelegatedTasks(); runDelegatedTasks();
break; break;
case NOT_HANDSHAKING:
case NEED_UNWRAP:
case NEED_WRAP:
break;
default:
throw new IllegalStateException(
"Unexpected handshake status: " +
result.getHandshakeStatus());
} }
if (result.bytesProduced() == 0) { if (result.bytesProduced() == 0) {
@ -621,12 +632,16 @@ public class SslHandler extends FrameDecoder {
runDelegatedTasks(); runDelegatedTasks();
break; break;
case FINISHED: case FINISHED:
case NOT_HANDSHAKING:
setHandshakeSuccess(channel); setHandshakeSuccess(channel);
wrap(ctx, channel); wrap(ctx, channel);
break loop; break loop;
default: case NOT_HANDSHAKING:
wrap(ctx, channel);
break loop; break loop;
default:
throw new IllegalStateException(
"Unknown handshake status: " +
result.getHandshakeStatus());
} }
} }
@ -664,10 +679,6 @@ public class SslHandler extends FrameDecoder {
} }
private void setHandshakeSuccess(Channel channel) { private void setHandshakeSuccess(Channel channel) {
if (!handshaking) {
return;
}
synchronized (handshakeLock) { synchronized (handshakeLock) {
handshaking = false; handshaking = false;
handshaken = true; handshaken = true;