Fixed an issue: NETTY-16 (SSL handshake failure should be reported to the ChannelPipeline.)

* Added SslHandler.newHandshakeFuture() and replaced all handshake future creation code with it
This commit is contained in:
Trustin Lee 2008-08-18 11:30:58 +00:00
parent 49bac1aa73
commit 1837b20051

View File

@ -142,7 +142,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
if (handshaking) {
return this.handshakeFuture;
} else {
handshakeFuture = this.handshakeFuture = future(channel);
handshakeFuture = this.handshakeFuture = newHandshakeFuture(channel);
handshaking = true;
}
}
@ -504,7 +504,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
handshaken = true;
if (handshakeFuture != null) {
handshakeFuture = future(channel);
handshakeFuture = newHandshakeFuture(channel);
}
}
handshakeFuture.setSuccess();
@ -516,7 +516,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
handshaken = false;
if (handshakeFuture != null) {
handshakeFuture = future(channel);
handshakeFuture = newHandshakeFuture(channel);
}
}
handshakeFuture.setFailure(cause);
@ -541,6 +541,19 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
context.sendDownstream(e);
}
private static ChannelFuture newHandshakeFuture(Channel channel) {
ChannelFuture future = future(channel);
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future)
throws Exception {
if (!future.isSuccess()) {
fireExceptionCaught(future.getChannel(), future.getCause());
}
}
});
return future;
}
private static class PendingWrite {
final ChannelFuture future;
final ByteBuffer outAppBuf;