Fail all pending writes on channelClosed(..). See #305
This commit is contained in:
parent
250f1667b9
commit
769275e751
@ -476,7 +476,7 @@ public class SslHandler extends FrameDecoder
|
||||
context.sendDownstream(evt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MessageEvent e = (MessageEvent) evt;
|
||||
if (!(e.getMessage() instanceof ChannelBuffer)) {
|
||||
context.sendDownstream(evt);
|
||||
@ -1239,6 +1239,48 @@ public class SslHandler extends FrameDecoder
|
||||
super.channelConnected(ctx, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop over all the pending writes and fail them.
|
||||
*
|
||||
* See <a href="https://github.com/netty/netty/issues/305">#305</a> for more details.
|
||||
*/
|
||||
@Override
|
||||
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
||||
Throwable cause = null;
|
||||
synchronized (pendingUnencryptedWrites) {
|
||||
for (;;) {
|
||||
PendingWrite pw = pendingUnencryptedWrites.poll();
|
||||
if (pw == null) {
|
||||
break;
|
||||
}
|
||||
if (cause == null) {
|
||||
cause = new ClosedChannelException();
|
||||
}
|
||||
pw.future.setFailure(cause);
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (;;) {
|
||||
MessageEvent ev = pendingEncryptedWrites.poll();
|
||||
if (ev == null) {
|
||||
break;
|
||||
}
|
||||
if (cause == null) {
|
||||
cause = new ClosedChannelException();
|
||||
}
|
||||
ev.getFuture().setFailure(cause);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
fireExceptionCaught(ctx, cause);
|
||||
}
|
||||
|
||||
super.channelClosed(ctx, e);
|
||||
}
|
||||
|
||||
private final class SSLEngineInboundCloseFuture extends DefaultChannelFuture {
|
||||
public SSLEngineInboundCloseFuture() {
|
||||
super(null, true);
|
||||
|
Loading…
Reference in New Issue
Block a user