From 93fd73fbbf2054a6785bf58bcf40bfdd7c91bbfb Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 1 Jan 2013 00:26:52 +0900 Subject: [PATCH] Fix a bug in AioSocketChannel where inboundBufferSuspended() is triggered even if the channel is closed. --- .../channel/socket/aio/AioSocketChannel.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java index edee9347ee..81e22eb3aa 100755 --- a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java @@ -325,6 +325,10 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne inDoBeginRead = true; try { for (;;) { + if (inputShutdown) { + break; + } + ByteBuf byteBuf = pipeline().inboundByteBuffer(); if (!byteBuf.readable()) { byteBuf.discardReadBytes(); @@ -468,16 +472,16 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne pipeline.fireInboundBufferUpdated(); } - firedInboundBufferSuspended = true; - pipeline.fireInboundBufferSuspended(); + if (!closed && channel.isOpen()) { + firedInboundBufferSuspended = true; + pipeline.fireInboundBufferSuspended(); + } + pipeline.fireExceptionCaught(t); } finally { if (read) { pipeline.fireInboundBufferUpdated(); } - if (!firedInboundBufferSuspended) { - pipeline.fireInboundBufferSuspended(); - } // Double check because fireInboundBufferUpdated() might have triggered the closure by a user handler. if (closed || !channel.isOpen()) { @@ -489,6 +493,8 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne channel.unsafe().close(channel.unsafe().voidFuture()); } } + } else if (!firedInboundBufferSuspended) { + pipeline.fireInboundBufferSuspended(); } } }