Notify ChannelFuture's of queued writes if the SslHandler gets removed from the ChannelPipeline. See #306

This commit is contained in:
norman 2012-05-04 09:49:37 +02:00
parent 33ff0421e2
commit 2a249c14b1

View File

@ -1222,8 +1222,40 @@ public class SslHandler extends FrameDecoder
// Unused
}
/**
* Fail all pending writes which we were not able to flush out
*/
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
// there is no need for synchronization here as we do not receive downstream events anymore
Throwable cause = null;
for (;;) {
PendingWrite pw = pendingUnencryptedWrites.poll();
if (pw == null) {
break;
}
if (cause == null) {
cause = new IOException("Unable to write data");
}
pw.future.setFailure(cause);
}
for (;;) {
MessageEvent ev = pendingEncryptedWrites.poll();
if (ev == null) {
break;
}
if (cause == null) {
cause = new IOException("Unable to write data");
}
ev.getFuture().setFailure(cause);
}
if (cause != null) {
fireExceptionCaught(ctx, cause);
}
}