Fixed a bug: NETTY-56 (The ChannFuture returned by SslHandler.handshake() is not completed when the associated Channel is closed during handshake.)
This commit is contained in:
parent
b378c083ec
commit
dddf14f79a
@ -25,6 +25,7 @@ package org.jboss.netty.handler.ssl;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
@ -339,6 +340,15 @@ public class SslHandler extends FrameDecoder {
|
||||
@Override
|
||||
public void channelDisconnected(ChannelHandlerContext ctx,
|
||||
ChannelStateEvent e) throws Exception {
|
||||
|
||||
// Make sure the handshake future is notified when a connection has
|
||||
// been closed during handshake.
|
||||
synchronized (handshakeLock) {
|
||||
if (handshaking) {
|
||||
handshakeFuture.setFailure(new ClosedChannelException());
|
||||
}
|
||||
}
|
||||
|
||||
super.channelDisconnected(ctx, e);
|
||||
unwrap(ctx, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
|
||||
engine.closeOutbound();
|
||||
|
@ -124,7 +124,13 @@ public abstract class AbstractSocketSslEchoTest {
|
||||
assertTrue(ccf.awaitUninterruptibly().isSuccess());
|
||||
|
||||
Channel cc = ccf.getChannel();
|
||||
assertTrue(cc.getPipeline().get(SslHandler.class).handshake(cc).awaitUninterruptibly().isSuccess());
|
||||
ChannelFuture hf = cc.getPipeline().get(SslHandler.class).handshake(cc);
|
||||
hf.awaitUninterruptibly();
|
||||
if (!hf.isSuccess() && ch.exception.get() != null) {
|
||||
ch.exception.get().printStackTrace();
|
||||
}
|
||||
|
||||
assertTrue(hf.isSuccess());
|
||||
|
||||
for (int i = 0; i < data.length;) {
|
||||
int length = Math.min(random.nextInt(1024 * 64), data.length - i);
|
||||
|
Loading…
Reference in New Issue
Block a user